<!-- HTML header for doxygen 1.8.8-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <!-- For Mobile Devices -->
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
        <meta name="generator" content="Doxygen 1.8.17"/>
        <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
        <title>QuEST: QuEST_cpu_distributed.c File Reference</title>
        <!--<link href="tabs.css" rel="stylesheet" type="text/css"/>-->
        <script type="text/javascript" src="dynsections.js"></script>
        <link href="doxygen.css" rel="stylesheet" type="text/css" />
        <link href="style.css" rel="stylesheet" type="text/css"/>
        <link href='https://fonts.googleapis.com/css?family=Roboto+Slab' rel='stylesheet' type='text/css'>
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
        <link href="jquery.smartmenus.bootstrap.css" rel="stylesheet">
        <script type="text/javascript" src="jquery.smartmenus.js"></script>
        <!-- SmartMenus jQuery Bootstrap Addon -->
        <script type="text/javascript" src="jquery.smartmenus.bootstrap.js"></script>
        <!-- SmartMenus jQuery plugin -->
    </head>
    <body>
        <nav class="navbar navbar-default" role="navigation">
            <div class="container">
                <div class="navbar-header">
                    <a class="navbar-brand"><img alt="Logo" src="logo.png"/></a>
                    <a class="navbar-brand"><b>QuEST</b> v3.2.0<br>The Quantum Exact Simulation Toolkit</a>
                </div>
            </div>
        </nav>
        <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
            <div class="content" id="content">
                <div class="container">
                    <div class="row">
                        <div class="col-sm-12 panel " style="padding-bottom: 15px;">
                            <div style="margin-bottom: 15px;">
<!-- end header part -->
<!-- Generated by Doxygen 1.8.17 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',false,false,'search.php','Search');
});
/* @license-end */</script>
<div id="main-nav"></div>
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_d522931ffa1371640980b621734a4381.html">Users</a></li><li class="navelem"><a class="el" href="dir_70834f0dcd10de01d2e35ab402a2238e.html">tysonjones</a></li><li class="navelem"><a class="el" href="dir_1957401ef452be7528010ba0f4832a45.html">Desktop</a></li><li class="navelem"><a class="el" href="dir_dee4414d5d72b49a9429e079789ffd08.html">GithubRepos</a></li><li class="navelem"><a class="el" href="dir_a89b43d59316bb5045aa22bb53a67d29.html">QuEST</a></li><li class="navelem"><a class="el" href="dir_f1fe56bf5ef15ff22696c757278c6962.html">QuEST</a></li><li class="navelem"><a class="el" href="dir_757750313c878cfe3b7d1ade55b4b819.html">src</a></li><li class="navelem"><a class="el" href="dir_b42f528141150d9931abf34c4623dde5.html">CPU</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#define-members">Macros</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">QuEST_cpu_distributed.c File Reference</div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><code>#include &quot;<a class="el" href="QuEST_8h_source.html">QuEST.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="QuEST__internal_8h_source.html">QuEST_internal.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="QuEST__precision_8h_source.html">QuEST_precision.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="QuEST__validation_8h_source.html">QuEST_validation.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="mt19937ar_8h_source.html">mt19937ar.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="QuEST__cpu__internal_8h_source.html">QuEST_cpu_internal.h</a>&quot;</code><br />
<code>#include &lt;unistd.h&gt;</code><br />
<code>#include &lt;mpi.h&gt;</code><br />
<code>#include &lt;stdlib.h&gt;</code><br />
<code>#include &lt;stdio.h&gt;</code><br />
<code>#include &lt;string.h&gt;</code><br />
<code>#include &lt;math.h&gt;</code><br />
<code>#include &lt;time.h&gt;</code><br />
<code>#include &lt;sys/types.h&gt;</code><br />
</div>
<p><a href="QuEST__cpu__distributed_8c_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:ad3d8a3bd0c0b677acef144f2c2ef6d73"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#ad3d8a3bd0c0b677acef144f2c2ef6d73">_BSD_SOURCE</a></td></tr>
<tr class="separator:ad3d8a3bd0c0b677acef144f2c2ef6d73"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a0552889d6f57d9e0ed8b209bf426482d"><td class="memItemLeft" align="right" valign="top">static int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#a0552889d6f57d9e0ed8b209bf426482d">chunkIsUpper</a> (int chunkId, long long int chunkSize, int targetQubit)</td></tr>
<tr class="memdesc:a0552889d6f57d9e0ed8b209bf426482d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns whether a given chunk in position chunkId is in the upper or lower half of a block.  <a href="QuEST__cpu__distributed_8c.html#a0552889d6f57d9e0ed8b209bf426482d">More...</a><br /></td></tr>
<tr class="separator:a0552889d6f57d9e0ed8b209bf426482d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa3c2d644a2be7f0d3aa9f757527d306f"><td class="memItemLeft" align="right" valign="top">static int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#aa3c2d644a2be7f0d3aa9f757527d306f">chunkIsUpperInOuterBlock</a> (int chunkId, long long int chunkSize, int targetQubit, int numQubits)</td></tr>
<tr class="memdesc:aa3c2d644a2be7f0d3aa9f757527d306f"><td class="mdescLeft">&#160;</td><td class="mdescRight">fix &ndash; do with masking instead  <a href="QuEST__cpu__distributed_8c.html#aa3c2d644a2be7f0d3aa9f757527d306f">More...</a><br /></td></tr>
<tr class="separator:aa3c2d644a2be7f0d3aa9f757527d306f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0eb14d48920ea469b0904ae63b47b589"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#a0eb14d48920ea469b0904ae63b47b589">compressPairVectorForSingleQubitDepolarise</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit)</td></tr>
<tr class="separator:a0eb14d48920ea469b0904ae63b47b589"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a373394db1bf71b0be63585c0e9a52abb"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#a373394db1bf71b0be63585c0e9a52abb">compressPairVectorForTwoQubitDepolarise</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit, int qubit2)</td></tr>
<tr class="separator:a373394db1bf71b0be63585c0e9a52abb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aefba328e047e6ef4fd1ae4b56901aaa7"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#aefba328e047e6ef4fd1ae4b56901aaa7">copyDiagOpIntoMatrixPairState</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, <a class="el" href="structDiagonalOp.html">DiagonalOp</a> op)</td></tr>
<tr class="separator:aefba328e047e6ef4fd1ae4b56901aaa7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a95af772d87c461fc8abfd6d47b752ac2"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#a95af772d87c461fc8abfd6d47b752ac2">copyVecIntoMatrixPairState</a> (<a class="el" href="structQureg.html">Qureg</a> matr, <a class="el" href="structQureg.html">Qureg</a> vec)</td></tr>
<tr class="memdesc:a95af772d87c461fc8abfd6d47b752ac2"><td class="mdescLeft">&#160;</td><td class="mdescRight">This copies/clones vec (a statevector) into every node's matr pairState.  <a href="QuEST__cpu__distributed_8c.html#a95af772d87c461fc8abfd6d47b752ac2">More...</a><br /></td></tr>
<tr class="separator:a95af772d87c461fc8abfd6d47b752ac2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga8ba2c3388dd64d9348c3b091852d36d4"><td class="memItemLeft" align="right" valign="top"><a class="el" href="structQuESTEnv.html">QuESTEnv</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__type.html#ga8ba2c3388dd64d9348c3b091852d36d4">createQuESTEnv</a> (void)</td></tr>
<tr class="memdesc:ga8ba2c3388dd64d9348c3b091852d36d4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Create the QuEST execution environment.  <a href="group__type.html#ga8ba2c3388dd64d9348c3b091852d36d4">More...</a><br /></td></tr>
<tr class="separator:ga8ba2c3388dd64d9348c3b091852d36d4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a076fe6125da4d6037b8bc4d912df4015"><td class="memItemLeft" align="right" valign="top">static int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#a076fe6125da4d6037b8bc4d912df4015">densityMatrixBlockFitsInChunk</a> (long long int chunkSize, int numQubits, int targetQubit)</td></tr>
<tr class="separator:a076fe6125da4d6037b8bc4d912df4015"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aedd7ecccf2f09dd2f1c5d191950b51e6"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#aedd7ecccf2f09dd2f1c5d191950b51e6">densmatr_applyDiagonalOp</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, <a class="el" href="structDiagonalOp.html">DiagonalOp</a> op)</td></tr>
<tr class="separator:aedd7ecccf2f09dd2f1c5d191950b51e6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a70e3b0a2297c186d5c779af31459b4ca"><td class="memItemLeft" align="right" valign="top"><a class="el" href="structComplex.html">Complex</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#a70e3b0a2297c186d5c779af31459b4ca">densmatr_calcExpecDiagonalOp</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, <a class="el" href="structDiagonalOp.html">DiagonalOp</a> op)</td></tr>
<tr class="separator:a70e3b0a2297c186d5c779af31459b4ca"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa6c3f86010ad398f42b0577ea3bb5bcf"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#aa6c3f86010ad398f42b0577ea3bb5bcf">densmatr_calcFidelity</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, <a class="el" href="structQureg.html">Qureg</a> pureState)</td></tr>
<tr class="separator:aa6c3f86010ad398f42b0577ea3bb5bcf"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8c9da88f734b0862f4cce7d819e6d3b5"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#a8c9da88f734b0862f4cce7d819e6d3b5">densmatr_calcHilbertSchmidtDistance</a> (<a class="el" href="structQureg.html">Qureg</a> a, <a class="el" href="structQureg.html">Qureg</a> b)</td></tr>
<tr class="separator:a8c9da88f734b0862f4cce7d819e6d3b5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6ff3dc624b5fafe8edae4fe327c255a0"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#a6ff3dc624b5fafe8edae4fe327c255a0">densmatr_calcInnerProduct</a> (<a class="el" href="structQureg.html">Qureg</a> a, <a class="el" href="structQureg.html">Qureg</a> b)</td></tr>
<tr class="separator:a6ff3dc624b5fafe8edae4fe327c255a0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae37b3eff5d3affbc1edfe216cabc1c53"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#ae37b3eff5d3affbc1edfe216cabc1c53">densmatr_calcProbOfOutcome</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int measureQubit, int outcome)</td></tr>
<tr class="separator:ae37b3eff5d3affbc1edfe216cabc1c53"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae45eefa65f4ecd37bab84fade7cf7f1f"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#ae45eefa65f4ecd37bab84fade7cf7f1f">densmatr_calcPurity</a> (<a class="el" href="structQureg.html">Qureg</a> qureg)</td></tr>
<tr class="separator:ae45eefa65f4ecd37bab84fade7cf7f1f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6153547f245c05874161a105e9a2f02c"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#a6153547f245c05874161a105e9a2f02c">densmatr_calcTotalProb</a> (<a class="el" href="structQureg.html">Qureg</a> qureg)</td></tr>
<tr class="separator:a6153547f245c05874161a105e9a2f02c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae5ad68d054875913d0f7ec654840a9ec"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#ae5ad68d054875913d0f7ec654840a9ec">densmatr_initPureState</a> (<a class="el" href="structQureg.html">Qureg</a> targetQureg, <a class="el" href="structQureg.html">Qureg</a> copyQureg)</td></tr>
<tr class="separator:ae5ad68d054875913d0f7ec654840a9ec"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac501fe7b9d331be48359ce1546348f97"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#ac501fe7b9d331be48359ce1546348f97">densmatr_mixDamping</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> damping)</td></tr>
<tr class="separator:ac501fe7b9d331be48359ce1546348f97"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a398b60c4cb4fa2cf2ffc126de6c08da0"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#a398b60c4cb4fa2cf2ffc126de6c08da0">densmatr_mixDepolarising</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> depolLevel)</td></tr>
<tr class="separator:a398b60c4cb4fa2cf2ffc126de6c08da0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a43afa97e300b87bce7f3eb1213eb05f6"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#a43afa97e300b87bce7f3eb1213eb05f6">densmatr_mixTwoQubitDepolarising</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int qubit1, int qubit2, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> depolLevel)</td></tr>
<tr class="separator:a43afa97e300b87bce7f3eb1213eb05f6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaeff624226629d7063a8a776958a4f991"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__type.html#gaeff624226629d7063a8a776958a4f991">destroyQuESTEnv</a> (<a class="el" href="structQuESTEnv.html">QuESTEnv</a> env)</td></tr>
<tr class="memdesc:gaeff624226629d7063a8a776958a4f991"><td class="mdescLeft">&#160;</td><td class="mdescRight">Destroy the QuEST environment.  <a href="group__type.html#gaeff624226629d7063a8a776958a4f991">More...</a><br /></td></tr>
<tr class="separator:gaeff624226629d7063a8a776958a4f991"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a37dae401754961c9100b3c0907913c3e"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#a37dae401754961c9100b3c0907913c3e">exchangePairStateVectorHalves</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int pairRank)</td></tr>
<tr class="separator:a37dae401754961c9100b3c0907913c3e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae01c3eb75fd32de1a7e1dbc7a33a21e3"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#ae01c3eb75fd32de1a7e1dbc7a33a21e3">exchangeStateVectors</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int pairRank)</td></tr>
<tr class="separator:ae01c3eb75fd32de1a7e1dbc7a33a21e3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a28be36627b2dd9a0da63dd6f60121b06"><td class="memItemLeft" align="right" valign="top">static int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#a28be36627b2dd9a0da63dd6f60121b06">getChunkIdFromIndex</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, long long int index)</td></tr>
<tr class="separator:a28be36627b2dd9a0da63dd6f60121b06"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae66dc6569c6e4008c33d6739db422c08"><td class="memItemLeft" align="right" valign="top">static int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#ae66dc6569c6e4008c33d6739db422c08">getChunkOuterBlockPairId</a> (int <a class="el" href="QuEST__cpu__distributed_8c.html#a0552889d6f57d9e0ed8b209bf426482d">chunkIsUpper</a>, int chunkId, long long int chunkSize, int targetQubit, int numQubits)</td></tr>
<tr class="separator:ae66dc6569c6e4008c33d6739db422c08"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab1ec7f241b68b079c8e316d190af49ce"><td class="memItemLeft" align="right" valign="top">static int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#ab1ec7f241b68b079c8e316d190af49ce">getChunkOuterBlockPairIdForPart3</a> (int chunkIsUpperSmallerQubit, int chunkIsUpperBiggerQubit, int chunkId, long long int chunkSize, int smallerQubit, int biggerQubit, int numQubits)</td></tr>
<tr class="separator:ab1ec7f241b68b079c8e316d190af49ce"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7dba097f23f5d48dfdc9f3250444e2e4"><td class="memItemLeft" align="right" valign="top">static int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#a7dba097f23f5d48dfdc9f3250444e2e4">getChunkPairId</a> (int <a class="el" href="QuEST__cpu__distributed_8c.html#a0552889d6f57d9e0ed8b209bf426482d">chunkIsUpper</a>, int chunkId, long long int chunkSize, int targetQubit)</td></tr>
<tr class="memdesc:a7dba097f23f5d48dfdc9f3250444e2e4"><td class="mdescLeft">&#160;</td><td class="mdescRight">get position of corresponding chunk, holding values required to update values in my chunk (with chunkId) when rotating targetQubit.  <a href="QuEST__cpu__distributed_8c.html#a7dba097f23f5d48dfdc9f3250444e2e4">More...</a><br /></td></tr>
<tr class="separator:a7dba097f23f5d48dfdc9f3250444e2e4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4f243eb101c8e63f16cfd50300364cb7"><td class="memItemLeft" align="right" valign="top">long long int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#a4f243eb101c8e63f16cfd50300364cb7">getGlobalIndOfOddParityInChunk</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int qb1, int qb2)</td></tr>
<tr class="memdesc:a4f243eb101c8e63f16cfd50300364cb7"><td class="mdescLeft">&#160;</td><td class="mdescRight">returns -1 if this node contains no amplitudes where qb1 and qb2 have opposite parity, otherwise returns the global index of one of such contained amplitudes (not necessarily the first)  <a href="QuEST__cpu__distributed_8c.html#a4f243eb101c8e63f16cfd50300364cb7">More...</a><br /></td></tr>
<tr class="separator:a4f243eb101c8e63f16cfd50300364cb7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:adb4b0373425b282abed27742d0ce0872"><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#adb4b0373425b282abed27742d0ce0872">getRotAngle</a> (int <a class="el" href="QuEST__cpu__distributed_8c.html#a0552889d6f57d9e0ed8b209bf426482d">chunkIsUpper</a>, <a class="el" href="structComplex.html">Complex</a> *rot1, <a class="el" href="structComplex.html">Complex</a> *rot2, <a class="el" href="structComplex.html">Complex</a> alpha, <a class="el" href="structComplex.html">Complex</a> beta)</td></tr>
<tr class="memdesc:adb4b0373425b282abed27742d0ce0872"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get rotation values for a given chunk.  <a href="QuEST__cpu__distributed_8c.html#adb4b0373425b282abed27742d0ce0872">More...</a><br /></td></tr>
<tr class="separator:adb4b0373425b282abed27742d0ce0872"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5c9b2f129bdffaaba9857f6eddecbb17"><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#a5c9b2f129bdffaaba9857f6eddecbb17">getRotAngleFromUnitaryMatrix</a> (int <a class="el" href="QuEST__cpu__distributed_8c.html#a0552889d6f57d9e0ed8b209bf426482d">chunkIsUpper</a>, <a class="el" href="structComplex.html">Complex</a> *rot1, <a class="el" href="structComplex.html">Complex</a> *rot2, <a class="el" href="structComplexMatrix2.html">ComplexMatrix2</a> u)</td></tr>
<tr class="memdesc:a5c9b2f129bdffaaba9857f6eddecbb17"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get rotation values for a given chunk given a unitary matrix.  <a href="QuEST__cpu__distributed_8c.html#a5c9b2f129bdffaaba9857f6eddecbb17">More...</a><br /></td></tr>
<tr class="separator:a5c9b2f129bdffaaba9857f6eddecbb17"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4d043bb0cee54a5f94faf3ffc34a6790"><td class="memItemLeft" align="right" valign="top">static int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#a4d043bb0cee54a5f94faf3ffc34a6790">halfMatrixBlockFitsInChunk</a> (long long int chunkSize, int targetQubit)</td></tr>
<tr class="memdesc:a4d043bb0cee54a5f94faf3ffc34a6790"><td class="mdescLeft">&#160;</td><td class="mdescRight">return whether the current qubit rotation will use blocks that fit within a single chunk.  <a href="QuEST__cpu__distributed_8c.html#a4d043bb0cee54a5f94faf3ffc34a6790">More...</a><br /></td></tr>
<tr class="separator:a4d043bb0cee54a5f94faf3ffc34a6790"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af0ea25f00987af4c53f17c9cca62ab41"><td class="memItemLeft" align="right" valign="top">static int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#af0ea25f00987af4c53f17c9cca62ab41">isChunkToSkipInFindPZero</a> (int chunkId, long long int chunkSize, int measureQubit)</td></tr>
<tr class="memdesc:af0ea25f00987af4c53f17c9cca62ab41"><td class="mdescLeft">&#160;</td><td class="mdescRight">Find chunks to skip when calculating probability of qubit being zero.  <a href="QuEST__cpu__distributed_8c.html#af0ea25f00987af4c53f17c9cca62ab41">More...</a><br /></td></tr>
<tr class="separator:af0ea25f00987af4c53f17c9cca62ab41"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaf8a14ae79c3fb2c0b5f6255cc37bebf9"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__debug.html#gaf8a14ae79c3fb2c0b5f6255cc37bebf9">reportQuESTEnv</a> (<a class="el" href="structQuESTEnv.html">QuESTEnv</a> env)</td></tr>
<tr class="memdesc:gaf8a14ae79c3fb2c0b5f6255cc37bebf9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Report information about the QuEST environment.  <a href="group__debug.html#gaf8a14ae79c3fb2c0b5f6255cc37bebf9">More...</a><br /></td></tr>
<tr class="separator:gaf8a14ae79c3fb2c0b5f6255cc37bebf9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaa8437ef3bf135231e2916e64dde1c94e"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__debug.html#gaa8437ef3bf135231e2916e64dde1c94e">seedQuESTDefault</a> ()</td></tr>
<tr class="memdesc:gaa8437ef3bf135231e2916e64dde1c94e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Seed the Mersenne Twister used for random number generation in the QuEST environment with an example defualt seed.  <a href="group__debug.html#gaa8437ef3bf135231e2916e64dde1c94e">More...</a><br /></td></tr>
<tr class="separator:gaa8437ef3bf135231e2916e64dde1c94e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0fb948ddab4ca210e523aa3c52639df4"><td class="memItemLeft" align="right" valign="top"><a class="el" href="structComplex.html">Complex</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#a0fb948ddab4ca210e523aa3c52639df4">statevec_calcExpecDiagonalOp</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, <a class="el" href="structDiagonalOp.html">DiagonalOp</a> op)</td></tr>
<tr class="separator:a0fb948ddab4ca210e523aa3c52639df4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7ebd3198a198f4cd20840f64fd8b84d0"><td class="memItemLeft" align="right" valign="top"><a class="el" href="structComplex.html">Complex</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#a7ebd3198a198f4cd20840f64fd8b84d0">statevec_calcInnerProduct</a> (<a class="el" href="structQureg.html">Qureg</a> bra, <a class="el" href="structQureg.html">Qureg</a> ket)</td></tr>
<tr class="separator:a7ebd3198a198f4cd20840f64fd8b84d0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a63cb88a5f4eb12fef087435b8db3f8eb"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#a63cb88a5f4eb12fef087435b8db3f8eb">statevec_calcProbOfOutcome</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int measureQubit, int outcome)</td></tr>
<tr class="separator:a63cb88a5f4eb12fef087435b8db3f8eb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad65ad1b5ea6f30b0c6b4ffda96e1a8e6"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#ad65ad1b5ea6f30b0c6b4ffda96e1a8e6">statevec_calcTotalProb</a> (<a class="el" href="structQureg.html">Qureg</a> qureg)</td></tr>
<tr class="separator:ad65ad1b5ea6f30b0c6b4ffda96e1a8e6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab07dc84ee1f2034482f1c186576434be"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#ab07dc84ee1f2034482f1c186576434be">statevec_collapseToKnownProbOutcome</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int measureQubit, int outcome, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> totalStateProb)</td></tr>
<tr class="separator:ab07dc84ee1f2034482f1c186576434be"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aec63559e8b9ab0e17efe18d64d2ceca6"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#aec63559e8b9ab0e17efe18d64d2ceca6">statevec_compactUnitary</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit, <a class="el" href="structComplex.html">Complex</a> alpha, <a class="el" href="structComplex.html">Complex</a> beta)</td></tr>
<tr class="separator:aec63559e8b9ab0e17efe18d64d2ceca6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1275d604674224d87a173fb5bac78835"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#a1275d604674224d87a173fb5bac78835">statevec_controlledCompactUnitary</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int controlQubit, int targetQubit, <a class="el" href="structComplex.html">Complex</a> alpha, <a class="el" href="structComplex.html">Complex</a> beta)</td></tr>
<tr class="separator:a1275d604674224d87a173fb5bac78835"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:abb2eab4af99adcc59be24f4c91c6f6ad"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#abb2eab4af99adcc59be24f4c91c6f6ad">statevec_controlledNot</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int controlQubit, int targetQubit)</td></tr>
<tr class="separator:abb2eab4af99adcc59be24f4c91c6f6ad"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4e19ef93d01d7acea32ca646d623aedd"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#a4e19ef93d01d7acea32ca646d623aedd">statevec_controlledPauliY</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int controlQubit, int targetQubit)</td></tr>
<tr class="separator:a4e19ef93d01d7acea32ca646d623aedd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4a2fa262d3f0dba372797b9bd35d9fa5"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#a4a2fa262d3f0dba372797b9bd35d9fa5">statevec_controlledPauliYConj</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int controlQubit, int targetQubit)</td></tr>
<tr class="separator:a4a2fa262d3f0dba372797b9bd35d9fa5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:add9ca9956cdd81ed5d0b0f66168c04a3"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#add9ca9956cdd81ed5d0b0f66168c04a3">statevec_controlledUnitary</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int controlQubit, int targetQubit, <a class="el" href="structComplexMatrix2.html">ComplexMatrix2</a> u)</td></tr>
<tr class="separator:add9ca9956cdd81ed5d0b0f66168c04a3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:abd509244d57657e148e4084c5ab5d28f"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#abd509244d57657e148e4084c5ab5d28f">statevec_getImagAmp</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, long long int index)</td></tr>
<tr class="separator:abd509244d57657e148e4084c5ab5d28f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:abc9a9ef4344c7faaaf28ac25c76649b9"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#abc9a9ef4344c7faaaf28ac25c76649b9">statevec_getRealAmp</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, long long int index)</td></tr>
<tr class="separator:abc9a9ef4344c7faaaf28ac25c76649b9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af3fc7bd149c70f083b149050242cd55e"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#af3fc7bd149c70f083b149050242cd55e">statevec_hadamard</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit)</td></tr>
<tr class="separator:af3fc7bd149c70f083b149050242cd55e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0acfe30083d0bc2a84da196378a36122"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#a0acfe30083d0bc2a84da196378a36122">statevec_multiControlledMultiQubitUnitary</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, long long int ctrlMask, int *targs, int numTargs, <a class="el" href="structComplexMatrixN.html">ComplexMatrixN</a> u)</td></tr>
<tr class="memdesc:a0acfe30083d0bc2a84da196378a36122"><td class="mdescLeft">&#160;</td><td class="mdescRight">This calls swapQubitAmps only when it would involve a distributed communication; if the qubit chunks already fit in the node, it operates the unitary direct.  <a href="QuEST__cpu__distributed_8c.html#a0acfe30083d0bc2a84da196378a36122">More...</a><br /></td></tr>
<tr class="separator:a0acfe30083d0bc2a84da196378a36122"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:affbd18d7c2ed8d5bd5edb67116501145"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#affbd18d7c2ed8d5bd5edb67116501145">statevec_multiControlledTwoQubitUnitary</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, long long int ctrlMask, int q1, int q2, <a class="el" href="structComplexMatrix4.html">ComplexMatrix4</a> u)</td></tr>
<tr class="memdesc:affbd18d7c2ed8d5bd5edb67116501145"><td class="mdescLeft">&#160;</td><td class="mdescRight">This calls swapQubitAmps only when it would involve a distributed communication; if the qubit chunks already fit in the node, it operates the unitary direct.  <a href="QuEST__cpu__distributed_8c.html#affbd18d7c2ed8d5bd5edb67116501145">More...</a><br /></td></tr>
<tr class="separator:affbd18d7c2ed8d5bd5edb67116501145"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a600bda10463e2078ce746ec28f2d39c9"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#a600bda10463e2078ce746ec28f2d39c9">statevec_multiControlledUnitary</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, long long int ctrlQubitsMask, long long int ctrlFlipMask, int targetQubit, <a class="el" href="structComplexMatrix2.html">ComplexMatrix2</a> u)</td></tr>
<tr class="separator:a600bda10463e2078ce746ec28f2d39c9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1c82b5e914a8a39c5c7b782dbc16fa76"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#a1c82b5e914a8a39c5c7b782dbc16fa76">statevec_pauliX</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit)</td></tr>
<tr class="separator:a1c82b5e914a8a39c5c7b782dbc16fa76"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af1cca787f3b0e0c91ffb2495f9ad8d5a"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#af1cca787f3b0e0c91ffb2495f9ad8d5a">statevec_pauliY</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit)</td></tr>
<tr class="separator:af1cca787f3b0e0c91ffb2495f9ad8d5a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a81fbd2eccd0d0e5a3cece4df2f96cb92"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#a81fbd2eccd0d0e5a3cece4df2f96cb92">statevec_pauliYConj</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit)</td></tr>
<tr class="separator:a81fbd2eccd0d0e5a3cece4df2f96cb92"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab7478fcaf6357ab202d72853b672e375"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#ab7478fcaf6357ab202d72853b672e375">statevec_swapQubitAmps</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int qb1, int qb2)</td></tr>
<tr class="separator:ab7478fcaf6357ab202d72853b672e375"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac3735bd959600e57b2ee3a105666cddf"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="QuEST__cpu__distributed_8c.html#ac3735bd959600e57b2ee3a105666cddf">statevec_unitary</a> (<a class="el" href="structQureg.html">Qureg</a> qureg, int targetQubit, <a class="el" href="structComplexMatrix2.html">ComplexMatrix2</a> u)</td></tr>
<tr class="separator:ac3735bd959600e57b2ee3a105666cddf"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga8d31fe2d1ad4d01e2a1f5f6b8bc15b77"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__debug.html#ga8d31fe2d1ad4d01e2a1f5f6b8bc15b77">syncQuESTEnv</a> (<a class="el" href="structQuESTEnv.html">QuESTEnv</a> env)</td></tr>
<tr class="memdesc:ga8d31fe2d1ad4d01e2a1f5f6b8bc15b77"><td class="mdescLeft">&#160;</td><td class="mdescRight">Guarantees that all code up to the given point has been executed on all nodes (if running in distributed mode)  <a href="group__debug.html#ga8d31fe2d1ad4d01e2a1f5f6b8bc15b77">More...</a><br /></td></tr>
<tr class="separator:ga8d31fe2d1ad4d01e2a1f5f6b8bc15b77"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gac7e38d768a1bd79019f88cc1e6295092"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__debug.html#gac7e38d768a1bd79019f88cc1e6295092">syncQuESTSuccess</a> (int successCode)</td></tr>
<tr class="memdesc:gac7e38d768a1bd79019f88cc1e6295092"><td class="mdescLeft">&#160;</td><td class="mdescRight">Performs a logical AND on all successCodes held by all processes.  <a href="group__debug.html#gac7e38d768a1bd79019f88cc1e6295092">More...</a><br /></td></tr>
<tr class="separator:gac7e38d768a1bd79019f88cc1e6295092"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>An implementation of the backend in ../QuEST_ops.h for an MPI environment. Mostly pure-state wrappers for the local/distributed functions implemented in QuEST_cpu</p>
<dl class="section author"><dt>Author</dt><dd>Ania Brown </dd>
<dd>
Tyson Jones </dd>
<dd>
Balint Koczor </dd></dl>

<p class="definition">Definition in file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
</div><h2 class="groupheader">Macro Definition Documentation</h2>
<a id="ad3d8a3bd0c0b677acef144f2c2ef6d73"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad3d8a3bd0c0b677acef144f2c2ef6d73">&#9670;&nbsp;</a></span>_BSD_SOURCE</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define _BSD_SOURCE</td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00020">20</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a id="a0552889d6f57d9e0ed8b209bf426482d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a0552889d6f57d9e0ed8b209bf426482d">&#9670;&nbsp;</a></span>chunkIsUpper()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static int chunkIsUpper </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>chunkId</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long long int&#160;</td>
          <td class="paramname"><em>chunkSize</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Returns whether a given chunk in position chunkId is in the upper or lower half of a block. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">chunkId</td><td>id of chunk in state vector </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">chunkSize</td><td>number of amps in chunk </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">targetQubit</td><td>qubit being rotated </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>1: chunk is in upper half of block, 0: chunk is in lower half of block fix &ndash; is this the same as isChunkToSkip? </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00227">227</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00228"></a><span class="lineno">  228</span>&#160;{       </div>
<div class="line"><a name="l00229"></a><span class="lineno">  229</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> sizeHalfBlock = 1LL &lt;&lt; (targetQubit);</div>
<div class="line"><a name="l00230"></a><span class="lineno">  230</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> sizeBlock = sizeHalfBlock*2;</div>
<div class="line"><a name="l00231"></a><span class="lineno">  231</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> posInBlock = (chunkId*chunkSize) % sizeBlock;</div>
<div class="line"><a name="l00232"></a><span class="lineno">  232</span>&#160;    <span class="keywordflow">return</span> posInBlock&lt;sizeHalfBlock;</div>
<div class="line"><a name="l00233"></a><span class="lineno">  233</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">Referenced by <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00314">getChunkOuterBlockPairId()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00303">getChunkPairId()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00258">getRotAngle()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00283">getRotAngleFromUnitaryMatrix()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00844">statevec_compactUnitary()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00920">statevec_controlledCompactUnitary()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01061">statevec_controlledNot()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01140">statevec_controlledPauliY()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01173">statevec_controlledPauliYConj()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00958">statevec_controlledUnitary()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01206">statevec_hadamard()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00997">statevec_multiControlledUnitary()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01034">statevec_pauliX()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01090">statevec_pauliY()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01115">statevec_pauliYConj()</a>, and <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00881">statevec_unitary()</a>.</p>

</div>
</div>
<a id="aa3c2d644a2be7f0d3aa9f757527d306f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa3c2d644a2be7f0d3aa9f757527d306f">&#9670;&nbsp;</a></span>chunkIsUpperInOuterBlock()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static int chunkIsUpperInOuterBlock </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>chunkId</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long long int&#160;</td>
          <td class="paramname"><em>chunkSize</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numQubits</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>fix &ndash; do with masking instead </p>

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00236">236</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00237"></a><span class="lineno">  237</span>&#160;{       </div>
<div class="line"><a name="l00238"></a><span class="lineno">  238</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> sizeOuterHalfBlock = 1LL &lt;&lt; (targetQubit+numQubits);</div>
<div class="line"><a name="l00239"></a><span class="lineno">  239</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> sizeOuterBlock = sizeOuterHalfBlock*2;</div>
<div class="line"><a name="l00240"></a><span class="lineno">  240</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> posInBlock = (chunkId*chunkSize) % sizeOuterBlock;</div>
<div class="line"><a name="l00241"></a><span class="lineno">  241</span>&#160;    <span class="keywordflow">return</span> posInBlock&lt;sizeOuterHalfBlock;</div>
<div class="line"><a name="l00242"></a><span class="lineno">  242</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">Referenced by <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00725">densmatr_mixDamping()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00698">densmatr_mixDepolarising()</a>, and <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00752">densmatr_mixTwoQubitDepolarising()</a>.</p>

</div>
</div>
<a id="a0eb14d48920ea469b0904ae63b47b589"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a0eb14d48920ea469b0904ae63b47b589">&#9670;&nbsp;</a></span>compressPairVectorForSingleQubitDepolarise()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void compressPairVectorForSingleQubitDepolarise </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00543">543</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00543"></a><span class="lineno">  543</span>&#160;                                                                             {</div>
<div class="line"><a name="l00544"></a><span class="lineno">  544</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> sizeInnerBlock, sizeInnerHalfBlock;</div>
<div class="line"><a name="l00545"></a><span class="lineno">  545</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> sizeOuterColumn, sizeOuterHalfColumn;</div>
<div class="line"><a name="l00546"></a><span class="lineno">  546</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> thisInnerBlock, <span class="comment">// current block</span></div>
<div class="line"><a name="l00547"></a><span class="lineno">  547</span>&#160;         thisOuterColumn, <span class="comment">// current column in density matrix</span></div>
<div class="line"><a name="l00548"></a><span class="lineno">  548</span>&#160;         thisIndex,    <span class="comment">// current index in (density matrix representation) state vector</span></div>
<div class="line"><a name="l00549"></a><span class="lineno">  549</span>&#160;         thisIndexInOuterColumn,</div>
<div class="line"><a name="l00550"></a><span class="lineno">  550</span>&#160;         thisIndexInInnerBlock;</div>
<div class="line"><a name="l00551"></a><span class="lineno">  551</span>&#160;         </div>
<div class="line"><a name="l00552"></a><span class="lineno">  552</span>&#160;    <span class="keywordtype">int</span> outerBit;</div>
<div class="line"><a name="l00553"></a><span class="lineno">  553</span>&#160; </div>
<div class="line"><a name="l00554"></a><span class="lineno">  554</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> thisTask;</div>
<div class="line"><a name="l00555"></a><span class="lineno">  555</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> numTasks=qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>&gt;&gt;1;</div>
<div class="line"><a name="l00556"></a><span class="lineno">  556</span>&#160; </div>
<div class="line"><a name="l00557"></a><span class="lineno">  557</span>&#160;    <span class="comment">// set dimensions</span></div>
<div class="line"><a name="l00558"></a><span class="lineno">  558</span>&#160;    sizeInnerHalfBlock = 1LL &lt;&lt; targetQubit;</div>
<div class="line"><a name="l00559"></a><span class="lineno">  559</span>&#160;    sizeInnerBlock     = 2LL * sizeInnerHalfBlock;</div>
<div class="line"><a name="l00560"></a><span class="lineno">  560</span>&#160;    sizeOuterHalfColumn = 1LL &lt;&lt; qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>;</div>
<div class="line"><a name="l00561"></a><span class="lineno">  561</span>&#160;    sizeOuterColumn     = 2LL * sizeOuterHalfColumn;</div>
<div class="line"><a name="l00562"></a><span class="lineno">  562</span>&#160; </div>
<div class="line"><a name="l00563"></a><span class="lineno">  563</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l00564"></a><span class="lineno">  564</span>&#160;<span class="preprocessor"># pragma omp parallel \</span></div>
<div class="line"><a name="l00565"></a><span class="lineno">  565</span>&#160;<span class="preprocessor">    default  (none) \</span></div>
<div class="line"><a name="l00566"></a><span class="lineno">  566</span>&#160;<span class="preprocessor">    shared   (sizeInnerBlock,sizeInnerHalfBlock,sizeOuterColumn,sizeOuterHalfColumn, \</span></div>
<div class="line"><a name="l00567"></a><span class="lineno">  567</span>&#160;<span class="preprocessor">                qureg,numTasks,targetQubit) \</span></div>
<div class="line"><a name="l00568"></a><span class="lineno">  568</span>&#160;<span class="preprocessor">    private  (thisTask,thisInnerBlock,thisOuterColumn,thisIndex,thisIndexInOuterColumn, \</span></div>
<div class="line"><a name="l00569"></a><span class="lineno">  569</span>&#160;<span class="preprocessor">                thisIndexInInnerBlock,outerBit) </span></div>
<div class="line"><a name="l00570"></a><span class="lineno">  570</span>&#160;<span class="preprocessor"># endif</span></div>
<div class="line"><a name="l00571"></a><span class="lineno">  571</span>&#160;    {</div>
<div class="line"><a name="l00572"></a><span class="lineno">  572</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l00573"></a><span class="lineno">  573</span>&#160;<span class="preprocessor"># pragma omp for schedule (static)</span></div>
<div class="line"><a name="l00574"></a><span class="lineno">  574</span>&#160;<span class="preprocessor"># endif</span></div>
<div class="line"><a name="l00575"></a><span class="lineno">  575</span>&#160;        <span class="comment">// thisTask iterates over half the elements in this process&#39; chunk of the density matrix</span></div>
<div class="line"><a name="l00576"></a><span class="lineno">  576</span>&#160;        <span class="comment">// treat this as iterating over all columns, then iterating over half the values</span></div>
<div class="line"><a name="l00577"></a><span class="lineno">  577</span>&#160;        <span class="comment">// within one column.</span></div>
<div class="line"><a name="l00578"></a><span class="lineno">  578</span>&#160;        <span class="comment">// If this function has been called, this process&#39; chunk contains half an </span></div>
<div class="line"><a name="l00579"></a><span class="lineno">  579</span>&#160;        <span class="comment">// outer block or less</span></div>
<div class="line"><a name="l00580"></a><span class="lineno">  580</span>&#160;        <span class="keywordflow">for</span> (thisTask=0; thisTask&lt;numTasks; thisTask++) {</div>
<div class="line"><a name="l00581"></a><span class="lineno">  581</span>&#160;            <span class="comment">// we want to process all columns in the density matrix,</span></div>
<div class="line"><a name="l00582"></a><span class="lineno">  582</span>&#160;            <span class="comment">// updating the values for half of each column (one half of each inner block)</span></div>
<div class="line"><a name="l00583"></a><span class="lineno">  583</span>&#160;            thisOuterColumn = thisTask / sizeOuterHalfColumn;</div>
<div class="line"><a name="l00584"></a><span class="lineno">  584</span>&#160;            thisIndexInOuterColumn = thisTask&amp;(sizeOuterHalfColumn-1); <span class="comment">// thisTask % sizeOuterHalfColumn</span></div>
<div class="line"><a name="l00585"></a><span class="lineno">  585</span>&#160;            thisInnerBlock = thisIndexInOuterColumn/sizeInnerHalfBlock;</div>
<div class="line"><a name="l00586"></a><span class="lineno">  586</span>&#160;            <span class="comment">// get index in state vector corresponding to upper inner block</span></div>
<div class="line"><a name="l00587"></a><span class="lineno">  587</span>&#160;            thisIndexInInnerBlock = thisTask&amp;(sizeInnerHalfBlock-1); <span class="comment">// thisTask % sizeInnerHalfBlock</span></div>
<div class="line"><a name="l00588"></a><span class="lineno">  588</span>&#160;            thisIndex = thisOuterColumn*sizeOuterColumn + thisInnerBlock*sizeInnerBlock</div>
<div class="line"><a name="l00589"></a><span class="lineno">  589</span>&#160;                + thisIndexInInnerBlock;</div>
<div class="line"><a name="l00590"></a><span class="lineno">  590</span>&#160;            <span class="comment">// check if we are in the upper or lower half of an outer block</span></div>
<div class="line"><a name="l00591"></a><span class="lineno">  591</span>&#160;            outerBit = <a class="code" href="QuEST__gpu_8cu.html#aec1852e1a8e70d3690919ce8ab551ba0">extractBit</a>(targetQubit, (thisIndex+qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>*qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>)&gt;&gt;qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00592"></a><span class="lineno">  592</span>&#160;            <span class="comment">// if we are in the lower half of an outer block, shift to be in the lower half</span></div>
<div class="line"><a name="l00593"></a><span class="lineno">  593</span>&#160;            <span class="comment">// of the inner block as well (we want to dephase |0&gt;&lt;0| and |1&gt;&lt;1| only)</span></div>
<div class="line"><a name="l00594"></a><span class="lineno">  594</span>&#160;            thisIndex += outerBit*(sizeInnerHalfBlock);</div>
<div class="line"><a name="l00595"></a><span class="lineno">  595</span>&#160; </div>
<div class="line"><a name="l00596"></a><span class="lineno">  596</span>&#160;            <span class="comment">// NOTE: at this point thisIndex should be the index of the element we want to </span></div>
<div class="line"><a name="l00597"></a><span class="lineno">  597</span>&#160;            <span class="comment">// dephase in the chunk of the state vector on this process, in the </span></div>
<div class="line"><a name="l00598"></a><span class="lineno">  598</span>&#160;            <span class="comment">// density matrix representation. </span></div>
<div class="line"><a name="l00599"></a><span class="lineno">  599</span>&#160;            <span class="comment">// thisTask is the index of the pair element in pairStateVec</span></div>
<div class="line"><a name="l00600"></a><span class="lineno">  600</span>&#160;            <span class="comment">// we will populate the second half of pairStateVec with this process&#39;</span></div>
<div class="line"><a name="l00601"></a><span class="lineno">  601</span>&#160;            <span class="comment">// data to send</span></div>
<div class="line"><a name="l00602"></a><span class="lineno">  602</span>&#160; </div>
<div class="line"><a name="l00603"></a><span class="lineno">  603</span>&#160;            qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.real[thisTask+numTasks] = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real[thisIndex];</div>
<div class="line"><a name="l00604"></a><span class="lineno">  604</span>&#160;            qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.imag[thisTask+numTasks] = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag[thisIndex];</div>
<div class="line"><a name="l00605"></a><span class="lineno">  605</span>&#160; </div>
<div class="line"><a name="l00606"></a><span class="lineno">  606</span>&#160;        }</div>
<div class="line"><a name="l00607"></a><span class="lineno">  607</span>&#160;    }</div>
<div class="line"><a name="l00608"></a><span class="lineno">  608</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__gpu_8cu_source.html#l00082">extractBit()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00208">Qureg::numQubitsRepresented</a>, <a class="el" href="QuEST_8h_source.html#l00224">Qureg::pairStateVec</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00725">densmatr_mixDamping()</a>, and <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00698">densmatr_mixDepolarising()</a>.</p>

</div>
</div>
<a id="a373394db1bf71b0be63585c0e9a52abb"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a373394db1bf71b0be63585c0e9a52abb">&#9670;&nbsp;</a></span>compressPairVectorForTwoQubitDepolarise()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void compressPairVectorForTwoQubitDepolarise </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>qubit2</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00610">610</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00611"></a><span class="lineno">  611</span>&#160;                    {</div>
<div class="line"><a name="l00612"></a><span class="lineno">  612</span>&#160; </div>
<div class="line"><a name="l00613"></a><span class="lineno">  613</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> sizeInnerBlockQ1, sizeInnerHalfBlockQ1;</div>
<div class="line"><a name="l00614"></a><span class="lineno">  614</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> sizeInnerBlockQ2, sizeInnerHalfBlockQ2, sizeInnerQuarterBlockQ2;</div>
<div class="line"><a name="l00615"></a><span class="lineno">  615</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> sizeOuterColumn, sizeOuterQuarterColumn;</div>
<div class="line"><a name="l00616"></a><span class="lineno">  616</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> </div>
<div class="line"><a name="l00617"></a><span class="lineno">  617</span>&#160;         thisInnerBlockQ2,</div>
<div class="line"><a name="l00618"></a><span class="lineno">  618</span>&#160;         thisOuterColumn, <span class="comment">// current column in density matrix</span></div>
<div class="line"><a name="l00619"></a><span class="lineno">  619</span>&#160;         thisIndex,    <span class="comment">// current index in (density matrix representation) state vector</span></div>
<div class="line"><a name="l00620"></a><span class="lineno">  620</span>&#160;         thisIndexInOuterColumn,</div>
<div class="line"><a name="l00621"></a><span class="lineno">  621</span>&#160;         thisIndexInInnerBlockQ1,</div>
<div class="line"><a name="l00622"></a><span class="lineno">  622</span>&#160;         thisIndexInInnerBlockQ2,</div>
<div class="line"><a name="l00623"></a><span class="lineno">  623</span>&#160;         thisInnerBlockQ1InInnerBlockQ2;</div>
<div class="line"><a name="l00624"></a><span class="lineno">  624</span>&#160;    <span class="keywordtype">int</span> outerBitQ1, outerBitQ2;</div>
<div class="line"><a name="l00625"></a><span class="lineno">  625</span>&#160; </div>
<div class="line"><a name="l00626"></a><span class="lineno">  626</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> thisTask;</div>
<div class="line"><a name="l00627"></a><span class="lineno">  627</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> numTasks=qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>&gt;&gt;2;</div>
<div class="line"><a name="l00628"></a><span class="lineno">  628</span>&#160; </div>
<div class="line"><a name="l00629"></a><span class="lineno">  629</span>&#160;    <span class="comment">// set dimensions</span></div>
<div class="line"><a name="l00630"></a><span class="lineno">  630</span>&#160;    sizeInnerHalfBlockQ1 = 1LL &lt;&lt; targetQubit;</div>
<div class="line"><a name="l00631"></a><span class="lineno">  631</span>&#160;    sizeInnerHalfBlockQ2 = 1LL &lt;&lt; qubit2;</div>
<div class="line"><a name="l00632"></a><span class="lineno">  632</span>&#160;    sizeInnerQuarterBlockQ2 = sizeInnerHalfBlockQ2 &gt;&gt; 1;</div>
<div class="line"><a name="l00633"></a><span class="lineno">  633</span>&#160;    sizeInnerBlockQ2 = sizeInnerHalfBlockQ2 &lt;&lt; 1;</div>
<div class="line"><a name="l00634"></a><span class="lineno">  634</span>&#160;    sizeInnerBlockQ1 = 2LL * sizeInnerHalfBlockQ1;</div>
<div class="line"><a name="l00635"></a><span class="lineno">  635</span>&#160;    sizeOuterColumn = 1LL &lt;&lt; qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>;</div>
<div class="line"><a name="l00636"></a><span class="lineno">  636</span>&#160;    sizeOuterQuarterColumn = sizeOuterColumn &gt;&gt; 2;</div>
<div class="line"><a name="l00637"></a><span class="lineno">  637</span>&#160; </div>
<div class="line"><a name="l00638"></a><span class="lineno">  638</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l00639"></a><span class="lineno">  639</span>&#160;<span class="preprocessor"># pragma omp parallel \</span></div>
<div class="line"><a name="l00640"></a><span class="lineno">  640</span>&#160;<span class="preprocessor">    default  (none) \</span></div>
<div class="line"><a name="l00641"></a><span class="lineno">  641</span>&#160;<span class="preprocessor">    shared   (sizeInnerBlockQ1,sizeInnerHalfBlockQ1,sizeInnerQuarterBlockQ2,sizeInnerHalfBlockQ2,sizeInnerBlockQ2, \</span></div>
<div class="line"><a name="l00642"></a><span class="lineno">  642</span>&#160;<span class="preprocessor">                sizeOuterColumn,sizeOuterQuarterColumn,qureg,numTasks,targetQubit,qubit2) \</span></div>
<div class="line"><a name="l00643"></a><span class="lineno">  643</span>&#160;<span class="preprocessor">    private  (thisTask,thisInnerBlockQ2,thisOuterColumn,thisIndex,thisIndexInOuterColumn, \</span></div>
<div class="line"><a name="l00644"></a><span class="lineno">  644</span>&#160;<span class="preprocessor">                thisIndexInInnerBlockQ1,thisIndexInInnerBlockQ2,thisInnerBlockQ1InInnerBlockQ2,outerBitQ1,outerBitQ2) </span></div>
<div class="line"><a name="l00645"></a><span class="lineno">  645</span>&#160;<span class="preprocessor"># endif</span></div>
<div class="line"><a name="l00646"></a><span class="lineno">  646</span>&#160;    {</div>
<div class="line"><a name="l00647"></a><span class="lineno">  647</span>&#160;<span class="preprocessor"># ifdef _OPENMP</span></div>
<div class="line"><a name="l00648"></a><span class="lineno">  648</span>&#160;<span class="preprocessor"># pragma omp for schedule (static)</span></div>
<div class="line"><a name="l00649"></a><span class="lineno">  649</span>&#160;<span class="preprocessor"># endif</span></div>
<div class="line"><a name="l00650"></a><span class="lineno">  650</span>&#160;        <span class="comment">// thisTask iterates over half the elements in this process&#39; chunk of the density matrix</span></div>
<div class="line"><a name="l00651"></a><span class="lineno">  651</span>&#160;        <span class="comment">// treat this as iterating over all columns, then iterating over half the values</span></div>
<div class="line"><a name="l00652"></a><span class="lineno">  652</span>&#160;        <span class="comment">// within one column.</span></div>
<div class="line"><a name="l00653"></a><span class="lineno">  653</span>&#160;        <span class="comment">// If this function has been called, this process&#39; chunk contains half an </span></div>
<div class="line"><a name="l00654"></a><span class="lineno">  654</span>&#160;        <span class="comment">// outer block or less</span></div>
<div class="line"><a name="l00655"></a><span class="lineno">  655</span>&#160;        <span class="keywordflow">for</span> (thisTask=0; thisTask&lt;numTasks; thisTask++) {</div>
<div class="line"><a name="l00656"></a><span class="lineno">  656</span>&#160;            <span class="comment">// we want to process all columns in the density matrix,</span></div>
<div class="line"><a name="l00657"></a><span class="lineno">  657</span>&#160;            <span class="comment">// updating the values for half of each column (one half of each inner block)</span></div>
<div class="line"><a name="l00658"></a><span class="lineno">  658</span>&#160;            thisOuterColumn = thisTask / sizeOuterQuarterColumn;</div>
<div class="line"><a name="l00659"></a><span class="lineno">  659</span>&#160;            <span class="comment">// thisTask % sizeOuterQuarterColumn</span></div>
<div class="line"><a name="l00660"></a><span class="lineno">  660</span>&#160;            thisIndexInOuterColumn = thisTask&amp;(sizeOuterQuarterColumn-1);</div>
<div class="line"><a name="l00661"></a><span class="lineno">  661</span>&#160;            thisInnerBlockQ2 = thisIndexInOuterColumn / sizeInnerQuarterBlockQ2;</div>
<div class="line"><a name="l00662"></a><span class="lineno">  662</span>&#160;            <span class="comment">// thisTask % sizeInnerQuarterBlockQ2;</span></div>
<div class="line"><a name="l00663"></a><span class="lineno">  663</span>&#160;            thisIndexInInnerBlockQ2 = thisTask&amp;(sizeInnerQuarterBlockQ2-1);</div>
<div class="line"><a name="l00664"></a><span class="lineno">  664</span>&#160;            thisInnerBlockQ1InInnerBlockQ2 = thisIndexInInnerBlockQ2 / sizeInnerHalfBlockQ1;</div>
<div class="line"><a name="l00665"></a><span class="lineno">  665</span>&#160;            <span class="comment">// thisTask % sizeInnerHalfBlockQ1;</span></div>
<div class="line"><a name="l00666"></a><span class="lineno">  666</span>&#160;            thisIndexInInnerBlockQ1 = thisTask&amp;(sizeInnerHalfBlockQ1-1);</div>
<div class="line"><a name="l00667"></a><span class="lineno">  667</span>&#160; </div>
<div class="line"><a name="l00668"></a><span class="lineno">  668</span>&#160;            <span class="comment">// get index in state vector corresponding to upper inner block</span></div>
<div class="line"><a name="l00669"></a><span class="lineno">  669</span>&#160;            thisIndex = thisOuterColumn*sizeOuterColumn + thisInnerBlockQ2*sizeInnerBlockQ2</div>
<div class="line"><a name="l00670"></a><span class="lineno">  670</span>&#160;                + thisInnerBlockQ1InInnerBlockQ2*sizeInnerBlockQ1 + thisIndexInInnerBlockQ1;</div>
<div class="line"><a name="l00671"></a><span class="lineno">  671</span>&#160; </div>
<div class="line"><a name="l00672"></a><span class="lineno">  672</span>&#160;            <span class="comment">// check if we are in the upper or lower half of an outer block for Q1</span></div>
<div class="line"><a name="l00673"></a><span class="lineno">  673</span>&#160;            outerBitQ1 = <a class="code" href="QuEST__gpu_8cu.html#aec1852e1a8e70d3690919ce8ab551ba0">extractBit</a>(targetQubit, (thisIndex+qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>*qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>)&gt;&gt;qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00674"></a><span class="lineno">  674</span>&#160;            <span class="comment">// if we are in the lower half of an outer block, shift to be in the lower half</span></div>
<div class="line"><a name="l00675"></a><span class="lineno">  675</span>&#160;            <span class="comment">// of the inner block as well (we want to dephase |0&gt;&lt;0| and |1&gt;&lt;1| only)</span></div>
<div class="line"><a name="l00676"></a><span class="lineno">  676</span>&#160;            thisIndex += outerBitQ1*(sizeInnerHalfBlockQ1);</div>
<div class="line"><a name="l00677"></a><span class="lineno">  677</span>&#160; </div>
<div class="line"><a name="l00678"></a><span class="lineno">  678</span>&#160;            <span class="comment">// check if we are in the upper or lower half of an outer block for Q2</span></div>
<div class="line"><a name="l00679"></a><span class="lineno">  679</span>&#160;            outerBitQ2 = <a class="code" href="QuEST__gpu_8cu.html#aec1852e1a8e70d3690919ce8ab551ba0">extractBit</a>(qubit2, (thisIndex+qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>*qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>)&gt;&gt;qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00680"></a><span class="lineno">  680</span>&#160;            <span class="comment">// if we are in the lower half of an outer block, shift to be in the lower half</span></div>
<div class="line"><a name="l00681"></a><span class="lineno">  681</span>&#160;            <span class="comment">// of the inner block as well (we want to dephase |0&gt;&lt;0| and |1&gt;&lt;1| only)</span></div>
<div class="line"><a name="l00682"></a><span class="lineno">  682</span>&#160;            thisIndex += outerBitQ2*(sizeInnerQuarterBlockQ2&lt;&lt;1);</div>
<div class="line"><a name="l00683"></a><span class="lineno">  683</span>&#160; </div>
<div class="line"><a name="l00684"></a><span class="lineno">  684</span>&#160;            <span class="comment">// NOTE: at this point thisIndex should be the index of the element we want to </span></div>
<div class="line"><a name="l00685"></a><span class="lineno">  685</span>&#160;            <span class="comment">// dephase in the chunk of the state vector on this process, in the </span></div>
<div class="line"><a name="l00686"></a><span class="lineno">  686</span>&#160;            <span class="comment">// density matrix representation. </span></div>
<div class="line"><a name="l00687"></a><span class="lineno">  687</span>&#160;            <span class="comment">// thisTask is the index of the pair element in pairStateVec</span></div>
<div class="line"><a name="l00688"></a><span class="lineno">  688</span>&#160; </div>
<div class="line"><a name="l00689"></a><span class="lineno">  689</span>&#160;            <span class="comment">// state[thisIndex] = (1-depolLevel)*state[thisIndex] + depolLevel*(state[thisIndex]</span></div>
<div class="line"><a name="l00690"></a><span class="lineno">  690</span>&#160;            <span class="comment">//      + pair[thisTask])/2</span></div>
<div class="line"><a name="l00691"></a><span class="lineno">  691</span>&#160;            qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.real[thisTask+numTasks*2] = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real[thisIndex];</div>
<div class="line"><a name="l00692"></a><span class="lineno">  692</span>&#160;            qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.imag[thisTask+numTasks*2] = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag[thisIndex];</div>
<div class="line"><a name="l00693"></a><span class="lineno">  693</span>&#160;        }</div>
<div class="line"><a name="l00694"></a><span class="lineno">  694</span>&#160;    }</div>
<div class="line"><a name="l00695"></a><span class="lineno">  695</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__gpu_8cu_source.html#l00082">extractBit()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00208">Qureg::numQubitsRepresented</a>, <a class="el" href="QuEST_8h_source.html#l00224">Qureg::pairStateVec</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00752">densmatr_mixTwoQubitDepolarising()</a>.</p>

</div>
</div>
<a id="aefba328e047e6ef4fd1ae4b56901aaa7"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aefba328e047e6ef4fd1ae4b56901aaa7">&#9670;&nbsp;</a></span>copyDiagOpIntoMatrixPairState()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void copyDiagOpIntoMatrixPairState </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structDiagonalOp.html">DiagonalOp</a>&#160;</td>
          <td class="paramname"><em>op</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01482">1482</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01482"></a><span class="lineno"> 1482</span>&#160;                                                               {</div>
<div class="line"><a name="l01483"></a><span class="lineno"> 1483</span>&#160;        </div>
<div class="line"><a name="l01484"></a><span class="lineno"> 1484</span>&#160;    <span class="comment">/* since, for every elem in 2^N op, there is a column in 2^N x 2^N qureg, </span></div>
<div class="line"><a name="l01485"></a><span class="lineno"> 1485</span>&#160;<span class="comment">     * we know immediately (by each node containing at least 1 element of op)</span></div>
<div class="line"><a name="l01486"></a><span class="lineno"> 1486</span>&#160;<span class="comment">     * that every node contains at least 1 column. Hence, we know that pairStateVec </span></div>
<div class="line"><a name="l01487"></a><span class="lineno"> 1487</span>&#160;<span class="comment">     * of qureg can fit the entirety of op.</span></div>
<div class="line"><a name="l01488"></a><span class="lineno"> 1488</span>&#160;<span class="comment">     */</span></div>
<div class="line"><a name="l01489"></a><span class="lineno"> 1489</span>&#160; </div>
<div class="line"><a name="l01490"></a><span class="lineno"> 1490</span>&#160;    <span class="comment">// load up our local contribution</span></div>
<div class="line"><a name="l01491"></a><span class="lineno"> 1491</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> localOffset = qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a> * op.<a class="code" href="structDiagonalOp.html#a2c6eab631ef48b4978db026c98180eee">numElemsPerChunk</a>;</div>
<div class="line"><a name="l01492"></a><span class="lineno"> 1492</span>&#160;    memcpy(&amp;qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.real[localOffset], op.<a class="code" href="structDiagonalOp.html#a1d66088bed235d524cd452b107694d5c">real</a>, op.<a class="code" href="structDiagonalOp.html#a2c6eab631ef48b4978db026c98180eee">numElemsPerChunk</a> * <span class="keyword">sizeof</span>(<a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>));</div>
<div class="line"><a name="l01493"></a><span class="lineno"> 1493</span>&#160;    memcpy(&amp;qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.imag[localOffset], op.<a class="code" href="structDiagonalOp.html#a85c3f52533efe831bbe40b9a48602388">imag</a>, op.<a class="code" href="structDiagonalOp.html#a2c6eab631ef48b4978db026c98180eee">numElemsPerChunk</a> * <span class="keyword">sizeof</span>(<a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>));</div>
<div class="line"><a name="l01494"></a><span class="lineno"> 1494</span>&#160;    </div>
<div class="line"><a name="l01495"></a><span class="lineno"> 1495</span>&#160;    <span class="comment">// work out how many messages are needed to send op chunks (2GB limit)</span></div>
<div class="line"><a name="l01496"></a><span class="lineno"> 1496</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> maxMsgSize = MPI_MAX_AMPS_IN_MSG;</div>
<div class="line"><a name="l01497"></a><span class="lineno"> 1497</span>&#160;    <span class="keywordflow">if</span> (op.<a class="code" href="structDiagonalOp.html#a2c6eab631ef48b4978db026c98180eee">numElemsPerChunk</a> &lt; maxMsgSize) </div>
<div class="line"><a name="l01498"></a><span class="lineno"> 1498</span>&#160;        maxMsgSize = op.<a class="code" href="structDiagonalOp.html#a2c6eab631ef48b4978db026c98180eee">numElemsPerChunk</a>;</div>
<div class="line"><a name="l01499"></a><span class="lineno"> 1499</span>&#160;    <span class="keywordtype">int</span> numMsgs = op.<a class="code" href="structDiagonalOp.html#a2c6eab631ef48b4978db026c98180eee">numElemsPerChunk</a> / maxMsgSize; <span class="comment">// since MPI_MAX... = 2^n, division is exact</span></div>
<div class="line"><a name="l01500"></a><span class="lineno"> 1500</span>&#160;    </div>
<div class="line"><a name="l01501"></a><span class="lineno"> 1501</span>&#160;    <span class="comment">// each node has a turn at broadcasting its contribution of op</span></div>
<div class="line"><a name="l01502"></a><span class="lineno"> 1502</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> broadcaster=0; broadcaster &lt; qureg.<a class="code" href="structQureg.html#aa3deb7163aab90a61e755a1f200f5413">numChunks</a>; broadcaster++) {</div>
<div class="line"><a name="l01503"></a><span class="lineno"> 1503</span>&#160;        <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> broadOffset = broadcaster * op.<a class="code" href="structDiagonalOp.html#a2c6eab631ef48b4978db026c98180eee">numElemsPerChunk</a>;</div>
<div class="line"><a name="l01504"></a><span class="lineno"> 1504</span>&#160;    </div>
<div class="line"><a name="l01505"></a><span class="lineno"> 1505</span>&#160;        <span class="comment">// (while keeping each message smaller than MPI max)</span></div>
<div class="line"><a name="l01506"></a><span class="lineno"> 1506</span>&#160;        <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i&lt;numMsgs; i++) {</div>
<div class="line"><a name="l01507"></a><span class="lineno"> 1507</span>&#160;            MPI_Bcast(</div>
<div class="line"><a name="l01508"></a><span class="lineno"> 1508</span>&#160;                &amp;qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.real[broadOffset + i*maxMsgSize], </div>
<div class="line"><a name="l01509"></a><span class="lineno"> 1509</span>&#160;                maxMsgSize,  MPI_QuEST_REAL, broadcaster, MPI_COMM_WORLD);</div>
<div class="line"><a name="l01510"></a><span class="lineno"> 1510</span>&#160;            MPI_Bcast(</div>
<div class="line"><a name="l01511"></a><span class="lineno"> 1511</span>&#160;                &amp;qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.imag[broadOffset + i*maxMsgSize], </div>
<div class="line"><a name="l01512"></a><span class="lineno"> 1512</span>&#160;                maxMsgSize,  MPI_QuEST_REAL, broadcaster, MPI_COMM_WORLD);</div>
<div class="line"><a name="l01513"></a><span class="lineno"> 1513</span>&#160;        }</div>
<div class="line"><a name="l01514"></a><span class="lineno"> 1514</span>&#160;    }</div>
<div class="line"><a name="l01515"></a><span class="lineno"> 1515</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST_8h_source.html#l00191">DiagonalOp::imag</a>, <a class="el" href="QuEST_8h_source.html#l00219">Qureg::numChunks</a>, <a class="el" href="QuEST_8h_source.html#l00183">DiagonalOp::numElemsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00224">Qureg::pairStateVec</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00189">DiagonalOp::real</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01517">densmatr_applyDiagonalOp()</a>.</p>

</div>
</div>
<a id="a95af772d87c461fc8abfd6d47b752ac2"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a95af772d87c461fc8abfd6d47b752ac2">&#9670;&nbsp;</a></span>copyVecIntoMatrixPairState()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void copyVecIntoMatrixPairState </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>matr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>vec</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This copies/clones vec (a statevector) into every node's matr pairState. </p>
<p>(where matr is a density matrix or equal number of qubits as vec) </p>

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00371">371</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00371"></a><span class="lineno">  371</span>&#160;                                                       {</div>
<div class="line"><a name="l00372"></a><span class="lineno">  372</span>&#160;    </div>
<div class="line"><a name="l00373"></a><span class="lineno">  373</span>&#160;    <span class="comment">// Remember that for every amplitude that `vec` stores on the node,</span></div>
<div class="line"><a name="l00374"></a><span class="lineno">  374</span>&#160;    <span class="comment">// `matr` stores an entire column. Ergo there are always an integer</span></div>
<div class="line"><a name="l00375"></a><span class="lineno">  375</span>&#160;    <span class="comment">// number (in fact, a power of 2) number of  `matr`s columns on each node.</span></div>
<div class="line"><a name="l00376"></a><span class="lineno">  376</span>&#160;    <span class="comment">// Since the total size of `vec` (between all nodes) is one column</span></div>
<div class="line"><a name="l00377"></a><span class="lineno">  377</span>&#160;    <span class="comment">// and each node stores (possibly) multiple columns (vec.numAmpsPerChunk as many), </span></div>
<div class="line"><a name="l00378"></a><span class="lineno">  378</span>&#160;    <span class="comment">// `vec` can be fit entirely inside a single node&#39;s matr.pairStateVec (with excess!)</span></div>
<div class="line"><a name="l00379"></a><span class="lineno">  379</span>&#160;    </div>
<div class="line"><a name="l00380"></a><span class="lineno">  380</span>&#160;    <span class="comment">// copy this node&#39;s vec segment into this node&#39;s matr pairState (in the right spot)</span></div>
<div class="line"><a name="l00381"></a><span class="lineno">  381</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> numLocalAmps = vec.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l00382"></a><span class="lineno">  382</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> myOffset = vec.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a> * numLocalAmps;</div>
<div class="line"><a name="l00383"></a><span class="lineno">  383</span>&#160;    memcpy(&amp;matr.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.real[myOffset], vec.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real, numLocalAmps * <span class="keyword">sizeof</span>(<a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>));</div>
<div class="line"><a name="l00384"></a><span class="lineno">  384</span>&#160;    memcpy(&amp;matr.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.imag[myOffset], vec.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag, numLocalAmps * <span class="keyword">sizeof</span>(<a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>));</div>
<div class="line"><a name="l00385"></a><span class="lineno">  385</span>&#160;    </div>
<div class="line"><a name="l00386"></a><span class="lineno">  386</span>&#160;    <span class="comment">// we now want to share this node&#39;s vec segment with other node, so that </span></div>
<div class="line"><a name="l00387"></a><span class="lineno">  387</span>&#160;    <span class="comment">// vec is cloned in every node&#39;s matr.pairStateVec </span></div>
<div class="line"><a name="l00388"></a><span class="lineno">  388</span>&#160; </div>
<div class="line"><a name="l00389"></a><span class="lineno">  389</span>&#160;    <span class="comment">// work out how many messages needed to send vec chunks (2GB limit)</span></div>
<div class="line"><a name="l00390"></a><span class="lineno">  390</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> maxMsgSize = MPI_MAX_AMPS_IN_MSG;</div>
<div class="line"><a name="l00391"></a><span class="lineno">  391</span>&#160;    <span class="keywordflow">if</span> (numLocalAmps &lt; maxMsgSize) </div>
<div class="line"><a name="l00392"></a><span class="lineno">  392</span>&#160;        maxMsgSize = numLocalAmps;</div>
<div class="line"><a name="l00393"></a><span class="lineno">  393</span>&#160;    <span class="comment">// safely assume MPI_MAX... = 2^n, so division always exact:</span></div>
<div class="line"><a name="l00394"></a><span class="lineno">  394</span>&#160;    <span class="keywordtype">int</span> numMsgs = numLocalAmps / maxMsgSize;</div>
<div class="line"><a name="l00395"></a><span class="lineno">  395</span>&#160;    </div>
<div class="line"><a name="l00396"></a><span class="lineno">  396</span>&#160;    <span class="comment">// every node gets a turn at being the broadcaster</span></div>
<div class="line"><a name="l00397"></a><span class="lineno">  397</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> broadcaster=0; broadcaster &lt; vec.<a class="code" href="structQureg.html#aa3deb7163aab90a61e755a1f200f5413">numChunks</a>; broadcaster++) {</div>
<div class="line"><a name="l00398"></a><span class="lineno">  398</span>&#160;        </div>
<div class="line"><a name="l00399"></a><span class="lineno">  399</span>&#160;        <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> otherOffset = broadcaster * numLocalAmps;</div>
<div class="line"><a name="l00400"></a><span class="lineno">  400</span>&#160;    </div>
<div class="line"><a name="l00401"></a><span class="lineno">  401</span>&#160;        <span class="comment">// every node sends a slice of qureg&#39;s pairState to every other</span></div>
<div class="line"><a name="l00402"></a><span class="lineno">  402</span>&#160;        <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0; i&lt; numMsgs; i++) {</div>
<div class="line"><a name="l00403"></a><span class="lineno">  403</span>&#160;    </div>
<div class="line"><a name="l00404"></a><span class="lineno">  404</span>&#160;            <span class="comment">// by sending that slice in further slices (due to bandwidth limit)</span></div>
<div class="line"><a name="l00405"></a><span class="lineno">  405</span>&#160;            MPI_Bcast(</div>
<div class="line"><a name="l00406"></a><span class="lineno">  406</span>&#160;                &amp;matr.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.real[otherOffset + i*maxMsgSize], </div>
<div class="line"><a name="l00407"></a><span class="lineno">  407</span>&#160;                maxMsgSize,  MPI_QuEST_REAL, broadcaster, MPI_COMM_WORLD);</div>
<div class="line"><a name="l00408"></a><span class="lineno">  408</span>&#160;            MPI_Bcast(</div>
<div class="line"><a name="l00409"></a><span class="lineno">  409</span>&#160;                &amp;matr.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.imag[otherOffset + i*maxMsgSize], </div>
<div class="line"><a name="l00410"></a><span class="lineno">  410</span>&#160;                maxMsgSize,  MPI_QuEST_REAL, broadcaster, MPI_COMM_WORLD);</div>
<div class="line"><a name="l00411"></a><span class="lineno">  411</span>&#160;        }</div>
<div class="line"><a name="l00412"></a><span class="lineno">  412</span>&#160;    }</div>
<div class="line"><a name="l00413"></a><span class="lineno">  413</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00219">Qureg::numChunks</a>, <a class="el" href="QuEST_8h_source.html#l00224">Qureg::pairStateVec</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00415">densmatr_calcFidelity()</a>, and <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00452">densmatr_initPureState()</a>.</p>

</div>
</div>
<a id="a076fe6125da4d6037b8bc4d912df4015"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a076fe6125da4d6037b8bc4d912df4015">&#9670;&nbsp;</a></span>densityMatrixBlockFitsInChunk()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static int densityMatrixBlockFitsInChunk </td>
          <td>(</td>
          <td class="paramtype">long long int&#160;</td>
          <td class="paramname"><em>chunkSize</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numQubits</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00363">363</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00363"></a><span class="lineno">  363</span>&#160;                                                                                                  {</div>
<div class="line"><a name="l00364"></a><span class="lineno">  364</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> sizeOuterHalfBlock = 1LL &lt;&lt; (targetQubit+numQubits);</div>
<div class="line"><a name="l00365"></a><span class="lineno">  365</span>&#160;    <span class="keywordflow">if</span> (chunkSize &gt; sizeOuterHalfBlock) <span class="keywordflow">return</span> 1;</div>
<div class="line"><a name="l00366"></a><span class="lineno">  366</span>&#160;    <span class="keywordflow">else</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><a name="l00367"></a><span class="lineno">  367</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">Referenced by <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00725">densmatr_mixDamping()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00698">densmatr_mixDepolarising()</a>, and <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00752">densmatr_mixTwoQubitDepolarising()</a>.</p>

</div>
</div>
<a id="aedd7ecccf2f09dd2f1c5d191950b51e6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aedd7ecccf2f09dd2f1c5d191950b51e6">&#9670;&nbsp;</a></span>densmatr_applyDiagonalOp()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void densmatr_applyDiagonalOp </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structDiagonalOp.html">DiagonalOp</a>&#160;</td>
          <td class="paramname"><em>op</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01517">1517</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01517"></a><span class="lineno"> 1517</span>&#160;                                                          {</div>
<div class="line"><a name="l01518"></a><span class="lineno"> 1518</span>&#160;    </div>
<div class="line"><a name="l01519"></a><span class="lineno"> 1519</span>&#160;    <a class="code" href="QuEST__cpu__distributed_8c.html#aefba328e047e6ef4fd1ae4b56901aaa7">copyDiagOpIntoMatrixPairState</a>(qureg, op);</div>
<div class="line"><a name="l01520"></a><span class="lineno"> 1520</span>&#160;    <a class="code" href="QuEST__cpu_8c.html#afa58cf7cb98a25ab33621120c5c330d0">densmatr_applyDiagonalOpLocal</a>(qureg, op);</div>
<div class="line"><a name="l01521"></a><span class="lineno"> 1521</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01482">copyDiagOpIntoMatrixPairState()</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l03696">densmatr_applyDiagonalOpLocal()</a>.</p>

</div>
</div>
<a id="a70e3b0a2297c186d5c779af31459b4ca"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a70e3b0a2297c186d5c779af31459b4ca">&#9670;&nbsp;</a></span>densmatr_calcExpecDiagonalOp()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="structComplex.html">Complex</a> densmatr_calcExpecDiagonalOp </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structDiagonalOp.html">DiagonalOp</a>&#160;</td>
          <td class="paramname"><em>op</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01541">1541</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01541"></a><span class="lineno"> 1541</span>&#160;                                                                 {</div>
<div class="line"><a name="l01542"></a><span class="lineno"> 1542</span>&#160;    </div>
<div class="line"><a name="l01543"></a><span class="lineno"> 1543</span>&#160;    <a class="code" href="structComplex.html">Complex</a> localVal = <a class="code" href="QuEST__cpu_8c.html#aeb4453a2e609e5359d2995bccf6663ca">densmatr_calcExpecDiagonalOpLocal</a>(qureg, op);</div>
<div class="line"><a name="l01544"></a><span class="lineno"> 1544</span>&#160;    <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#aa3deb7163aab90a61e755a1f200f5413">numChunks</a> == 1)</div>
<div class="line"><a name="l01545"></a><span class="lineno"> 1545</span>&#160;        <span class="keywordflow">return</span> localVal;</div>
<div class="line"><a name="l01546"></a><span class="lineno"> 1546</span>&#160;    </div>
<div class="line"><a name="l01547"></a><span class="lineno"> 1547</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> localRe = localVal.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a>;</div>
<div class="line"><a name="l01548"></a><span class="lineno"> 1548</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> localIm = localVal.<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a>;</div>
<div class="line"><a name="l01549"></a><span class="lineno"> 1549</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> globalRe, globalIm;</div>
<div class="line"><a name="l01550"></a><span class="lineno"> 1550</span>&#160;    </div>
<div class="line"><a name="l01551"></a><span class="lineno"> 1551</span>&#160;    MPI_Allreduce(&amp;localRe, &amp;globalRe, 1, MPI_QuEST_REAL, MPI_SUM, MPI_COMM_WORLD);</div>
<div class="line"><a name="l01552"></a><span class="lineno"> 1552</span>&#160;    MPI_Allreduce(&amp;localIm, &amp;globalIm, 1, MPI_QuEST_REAL, MPI_SUM, MPI_COMM_WORLD);</div>
<div class="line"><a name="l01553"></a><span class="lineno"> 1553</span>&#160;    </div>
<div class="line"><a name="l01554"></a><span class="lineno"> 1554</span>&#160;    <a class="code" href="structComplex.html">Complex</a> globalVal;</div>
<div class="line"><a name="l01555"></a><span class="lineno"> 1555</span>&#160;    globalVal.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a> = globalRe;</div>
<div class="line"><a name="l01556"></a><span class="lineno"> 1556</span>&#160;    globalVal.<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a> = globalIm;</div>
<div class="line"><a name="l01557"></a><span class="lineno"> 1557</span>&#160;    <span class="keywordflow">return</span> globalVal;</div>
<div class="line"><a name="l01558"></a><span class="lineno"> 1558</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu_8c_source.html#l03781">densmatr_calcExpecDiagonalOpLocal()</a>, <a class="el" href="QuEST_8h_source.html#l00106">Complex::imag</a>, <a class="el" href="QuEST_8h_source.html#l00219">Qureg::numChunks</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00105">Complex::real</a>.</p>

</div>
</div>
<a id="aa6c3f86010ad398f42b0577ea3bb5bcf"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa6c3f86010ad398f42b0577ea3bb5bcf">&#9670;&nbsp;</a></span>densmatr_calcFidelity()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> densmatr_calcFidelity </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>pureState</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00415">415</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00415"></a><span class="lineno">  415</span>&#160;                                                          {</div>
<div class="line"><a name="l00416"></a><span class="lineno">  416</span>&#160;    </div>
<div class="line"><a name="l00417"></a><span class="lineno">  417</span>&#160;    <span class="comment">// set qureg&#39;s pairState is to be the full pureState (on every node)</span></div>
<div class="line"><a name="l00418"></a><span class="lineno">  418</span>&#160;    <a class="code" href="QuEST__cpu__distributed_8c.html#a95af772d87c461fc8abfd6d47b752ac2">copyVecIntoMatrixPairState</a>(qureg, pureState);</div>
<div class="line"><a name="l00419"></a><span class="lineno">  419</span>&#160; </div>
<div class="line"><a name="l00420"></a><span class="lineno">  420</span>&#160;    <span class="comment">// collect calcFidelityLocal by every machine</span></div>
<div class="line"><a name="l00421"></a><span class="lineno">  421</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> localSum = <a class="code" href="QuEST__cpu_8c.html#a7772f97cb4d92a9825bf3b7c82c3230c">densmatr_calcFidelityLocal</a>(qureg, pureState);</div>
<div class="line"><a name="l00422"></a><span class="lineno">  422</span>&#160;    </div>
<div class="line"><a name="l00423"></a><span class="lineno">  423</span>&#160;    <span class="comment">// sum each localSum</span></div>
<div class="line"><a name="l00424"></a><span class="lineno">  424</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> globalSum;</div>
<div class="line"><a name="l00425"></a><span class="lineno">  425</span>&#160;    MPI_Allreduce(&amp;localSum, &amp;globalSum, 1, MPI_QuEST_REAL, MPI_SUM, MPI_COMM_WORLD);</div>
<div class="line"><a name="l00426"></a><span class="lineno">  426</span>&#160;    </div>
<div class="line"><a name="l00427"></a><span class="lineno">  427</span>&#160;    <span class="keywordflow">return</span> globalSum;</div>
<div class="line"><a name="l00428"></a><span class="lineno">  428</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00371">copyVecIntoMatrixPairState()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l00990">densmatr_calcFidelityLocal()</a>, and <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>.</p>

</div>
</div>
<a id="a8c9da88f734b0862f4cce7d819e6d3b5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8c9da88f734b0862f4cce7d819e6d3b5">&#9670;&nbsp;</a></span>densmatr_calcHilbertSchmidtDistance()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> densmatr_calcHilbertSchmidtDistance </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>a</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>b</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00430">430</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00430"></a><span class="lineno">  430</span>&#160;                                                            {</div>
<div class="line"><a name="l00431"></a><span class="lineno">  431</span>&#160;    </div>
<div class="line"><a name="l00432"></a><span class="lineno">  432</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> localSum = <a class="code" href="QuEST__cpu_8c.html#a939897137596bb73ad7a028d0beaaa10">densmatr_calcHilbertSchmidtDistanceSquaredLocal</a>(a, b);</div>
<div class="line"><a name="l00433"></a><span class="lineno">  433</span>&#160;    </div>
<div class="line"><a name="l00434"></a><span class="lineno">  434</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> globalSum;</div>
<div class="line"><a name="l00435"></a><span class="lineno">  435</span>&#160;    MPI_Allreduce(&amp;localSum, &amp;globalSum, 1, MPI_QuEST_REAL, MPI_SUM, MPI_COMM_WORLD);</div>
<div class="line"><a name="l00436"></a><span class="lineno">  436</span>&#160;    </div>
<div class="line"><a name="l00437"></a><span class="lineno">  437</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> dist = sqrt(globalSum);</div>
<div class="line"><a name="l00438"></a><span class="lineno">  438</span>&#160;    <span class="keywordflow">return</span> dist;</div>
<div class="line"><a name="l00439"></a><span class="lineno">  439</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu_8c_source.html#l00923">densmatr_calcHilbertSchmidtDistanceSquaredLocal()</a>, and <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>.</p>

</div>
</div>
<a id="a6ff3dc624b5fafe8edae4fe327c255a0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6ff3dc624b5fafe8edae4fe327c255a0">&#9670;&nbsp;</a></span>densmatr_calcInnerProduct()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> densmatr_calcInnerProduct </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>a</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>b</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00441">441</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00441"></a><span class="lineno">  441</span>&#160;                                                  {</div>
<div class="line"><a name="l00442"></a><span class="lineno">  442</span>&#160;    </div>
<div class="line"><a name="l00443"></a><span class="lineno">  443</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> localSum = <a class="code" href="QuEST__cpu_8c.html#a08392b1b27d10e3b8a8648a5afeaa629">densmatr_calcInnerProductLocal</a>(a, b);</div>
<div class="line"><a name="l00444"></a><span class="lineno">  444</span>&#160;    </div>
<div class="line"><a name="l00445"></a><span class="lineno">  445</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> globalSum;</div>
<div class="line"><a name="l00446"></a><span class="lineno">  446</span>&#160;    MPI_Allreduce(&amp;localSum, &amp;globalSum, 1, MPI_QuEST_REAL, MPI_SUM, MPI_COMM_WORLD);</div>
<div class="line"><a name="l00447"></a><span class="lineno">  447</span>&#160;    </div>
<div class="line"><a name="l00448"></a><span class="lineno">  448</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> dist = globalSum;</div>
<div class="line"><a name="l00449"></a><span class="lineno">  449</span>&#160;    <span class="keywordflow">return</span> dist;</div>
<div class="line"><a name="l00450"></a><span class="lineno">  450</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu_8c_source.html#l00958">densmatr_calcInnerProductLocal()</a>, and <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>.</p>

</div>
</div>
<a id="ae37b3eff5d3affbc1edfe216cabc1c53"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae37b3eff5d3affbc1edfe216cabc1c53">&#9670;&nbsp;</a></span>densmatr_calcProbOfOutcome()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> densmatr_calcProbOfOutcome </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>measureQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>outcome</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01276">1276</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01276"></a><span class="lineno"> 1276</span>&#160;                                                                             {</div>
<div class="line"><a name="l01277"></a><span class="lineno"> 1277</span>&#160;        </div>
<div class="line"><a name="l01278"></a><span class="lineno"> 1278</span>&#160;        <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> zeroProb = <a class="code" href="QuEST__cpu_8c.html#a8bea931504c90d9bd97e74645667804e">densmatr_findProbabilityOfZeroLocal</a>(qureg, measureQubit);</div>
<div class="line"><a name="l01279"></a><span class="lineno"> 1279</span>&#160;        </div>
<div class="line"><a name="l01280"></a><span class="lineno"> 1280</span>&#160;        <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> outcomeProb;</div>
<div class="line"><a name="l01281"></a><span class="lineno"> 1281</span>&#160;        MPI_Allreduce(&amp;zeroProb, &amp;outcomeProb, 1, MPI_QuEST_REAL, MPI_SUM, MPI_COMM_WORLD);</div>
<div class="line"><a name="l01282"></a><span class="lineno"> 1282</span>&#160;        <span class="keywordflow">if</span> (outcome == 1)</div>
<div class="line"><a name="l01283"></a><span class="lineno"> 1283</span>&#160;                outcomeProb = 1.0 - outcomeProb;</div>
<div class="line"><a name="l01284"></a><span class="lineno"> 1284</span>&#160;        </div>
<div class="line"><a name="l01285"></a><span class="lineno"> 1285</span>&#160;        <span class="keywordflow">return</span> outcomeProb;</div>
<div class="line"><a name="l01286"></a><span class="lineno"> 1286</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu_8c_source.html#l03151">densmatr_findProbabilityOfZeroLocal()</a>, and <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>.</p>

</div>
</div>
<a id="ae45eefa65f4ecd37bab84fade7cf7f1f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae45eefa65f4ecd37bab84fade7cf7f1f">&#9670;&nbsp;</a></span>densmatr_calcPurity()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> densmatr_calcPurity </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01288">1288</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01288"></a><span class="lineno"> 1288</span>&#160;                                       {</div>
<div class="line"><a name="l01289"></a><span class="lineno"> 1289</span>&#160;    </div>
<div class="line"><a name="l01290"></a><span class="lineno"> 1290</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> localPurity = <a class="code" href="QuEST__cpu_8c.html#af910c7cf2b85bdc2c399cfe8dbfb8b9c">densmatr_calcPurityLocal</a>(qureg);</div>
<div class="line"><a name="l01291"></a><span class="lineno"> 1291</span>&#160;        </div>
<div class="line"><a name="l01292"></a><span class="lineno"> 1292</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> globalPurity;</div>
<div class="line"><a name="l01293"></a><span class="lineno"> 1293</span>&#160;    MPI_Allreduce(&amp;localPurity, &amp;globalPurity, 1, MPI_QuEST_REAL, MPI_SUM, MPI_COMM_WORLD);</div>
<div class="line"><a name="l01294"></a><span class="lineno"> 1294</span>&#160;    </div>
<div class="line"><a name="l01295"></a><span class="lineno"> 1295</span>&#160;    <span class="keywordflow">return</span> globalPurity;</div>
<div class="line"><a name="l01296"></a><span class="lineno"> 1296</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu_8c_source.html#l00861">densmatr_calcPurityLocal()</a>, and <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>.</p>

</div>
</div>
<a id="a6153547f245c05874161a105e9a2f02c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6153547f245c05874161a105e9a2f02c">&#9670;&nbsp;</a></span>densmatr_calcTotalProb()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> densmatr_calcTotalProb </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00053">53</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;                                          {</div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;        </div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;        <span class="comment">// computes the trace by summing every element (&quot;diag&quot;) with global index (2^n + 1)i for i in [0, 2^n-1]</span></div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;        </div>
<div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;        <span class="comment">// computes first local index containing a diagonal element</span></div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;        <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> diagSpacing = 1LL + (1LL &lt;&lt; qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> numPrevDiags = (qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>&gt;0)? 1+(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>*qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>)/diagSpacing : 0;</div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;        <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> globalIndNextDiag = diagSpacing * numPrevDiags;</div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;        <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> localIndNextDiag = globalIndNextDiag % qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;        <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> index;</div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;        </div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;        <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> rankTotal = 0;</div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;        <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> y, t, c;</div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;        c = 0;</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;        </div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;        <span class="comment">// iterates every local diagonal</span></div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;        <span class="keywordflow">for</span> (index=localIndNextDiag; index &lt; qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>; index += diagSpacing) {</div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;                </div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;                <span class="comment">// Kahan summation - brackets are important</span></div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;                y = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real[index] - c;</div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;                t = rankTotal + y;</div>
<div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;                c = ( t - rankTotal ) - y;</div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;                rankTotal = t;</div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;        }</div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;        </div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;        <span class="comment">// combine each node&#39;s sum of diagonals</span></div>
<div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;        <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> globalTotal;</div>
<div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;        <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#aa3deb7163aab90a61e755a1f200f5413">numChunks</a> &gt; 1)</div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;                MPI_Allreduce(&amp;rankTotal, &amp;globalTotal, 1, MPI_QuEST_REAL, MPI_SUM, MPI_COMM_WORLD);</div>
<div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;        <span class="keywordflow">else</span></div>
<div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;                globalTotal = rankTotal;</div>
<div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;        </div>
<div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;        <span class="keywordflow">return</span> globalTotal;</div>
<div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00219">Qureg::numChunks</a>, <a class="el" href="QuEST_8h_source.html#l00208">Qureg::numQubitsRepresented</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>

</div>
</div>
<a id="ae5ad68d054875913d0f7ec654840a9ec"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae5ad68d054875913d0f7ec654840a9ec">&#9670;&nbsp;</a></span>densmatr_initPureState()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void densmatr_initPureState </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>targetQureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>copyQureg</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00452">452</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00452"></a><span class="lineno">  452</span>&#160;                                                                {</div>
<div class="line"><a name="l00453"></a><span class="lineno">  453</span>&#160; </div>
<div class="line"><a name="l00454"></a><span class="lineno">  454</span>&#160;    <span class="keywordflow">if</span> (targetQureg.<a class="code" href="structQureg.html#aa3deb7163aab90a61e755a1f200f5413">numChunks</a>==1){</div>
<div class="line"><a name="l00455"></a><span class="lineno">  455</span>&#160;        <span class="comment">// local version</span></div>
<div class="line"><a name="l00456"></a><span class="lineno">  456</span>&#160;        <span class="comment">// save pointers to qureg&#39;s pair state</span></div>
<div class="line"><a name="l00457"></a><span class="lineno">  457</span>&#160;        <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>* quregPairRePtr = targetQureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.real;</div>
<div class="line"><a name="l00458"></a><span class="lineno">  458</span>&#160;        <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>* quregPairImPtr = targetQureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.imag;</div>
<div class="line"><a name="l00459"></a><span class="lineno">  459</span>&#160; </div>
<div class="line"><a name="l00460"></a><span class="lineno">  460</span>&#160;        <span class="comment">// populate qureg pair state with pure state (by repointing)</span></div>
<div class="line"><a name="l00461"></a><span class="lineno">  461</span>&#160;        targetQureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.real = copyQureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real;</div>
<div class="line"><a name="l00462"></a><span class="lineno">  462</span>&#160;        targetQureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.imag = copyQureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag;</div>
<div class="line"><a name="l00463"></a><span class="lineno">  463</span>&#160; </div>
<div class="line"><a name="l00464"></a><span class="lineno">  464</span>&#160;        <span class="comment">// populate density matrix via it&#39;s pairState</span></div>
<div class="line"><a name="l00465"></a><span class="lineno">  465</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#a1b36518c8fbbc3a5084bb4ad1fb05ea5">densmatr_initPureStateLocal</a>(targetQureg, copyQureg);</div>
<div class="line"><a name="l00466"></a><span class="lineno">  466</span>&#160; </div>
<div class="line"><a name="l00467"></a><span class="lineno">  467</span>&#160;        <span class="comment">// restore pointers</span></div>
<div class="line"><a name="l00468"></a><span class="lineno">  468</span>&#160;        targetQureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.real = quregPairRePtr;</div>
<div class="line"><a name="l00469"></a><span class="lineno">  469</span>&#160;        targetQureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.imag = quregPairImPtr;</div>
<div class="line"><a name="l00470"></a><span class="lineno">  470</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00471"></a><span class="lineno">  471</span>&#160;        <span class="comment">// set qureg&#39;s pairState is to be the full pure state (on every node)</span></div>
<div class="line"><a name="l00472"></a><span class="lineno">  472</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#a95af772d87c461fc8abfd6d47b752ac2">copyVecIntoMatrixPairState</a>(targetQureg, copyQureg);</div>
<div class="line"><a name="l00473"></a><span class="lineno">  473</span>&#160;        </div>
<div class="line"><a name="l00474"></a><span class="lineno">  474</span>&#160;        <span class="comment">// update every density matrix chunk using pairState</span></div>
<div class="line"><a name="l00475"></a><span class="lineno">  475</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#a1b36518c8fbbc3a5084bb4ad1fb05ea5">densmatr_initPureStateLocal</a>(targetQureg, copyQureg);</div>
<div class="line"><a name="l00476"></a><span class="lineno">  476</span>&#160;    }</div>
<div class="line"><a name="l00477"></a><span class="lineno">  477</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00371">copyVecIntoMatrixPairState()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l01184">densmatr_initPureStateLocal()</a>, <a class="el" href="QuEST_8h_source.html#l00219">Qureg::numChunks</a>, <a class="el" href="QuEST_8h_source.html#l00224">Qureg::pairStateVec</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>

</div>
</div>
<a id="ac501fe7b9d331be48359ce1546348f97"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac501fe7b9d331be48359ce1546348f97">&#9670;&nbsp;</a></span>densmatr_mixDamping()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void densmatr_mixDamping </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>damping</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00725">725</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00725"></a><span class="lineno">  725</span>&#160;                                                                      {</div>
<div class="line"><a name="l00726"></a><span class="lineno">  726</span>&#160;    <span class="keywordflow">if</span> (damping == 0)</div>
<div class="line"><a name="l00727"></a><span class="lineno">  727</span>&#160;        <span class="keywordflow">return</span>;</div>
<div class="line"><a name="l00728"></a><span class="lineno">  728</span>&#160;    </div>
<div class="line"><a name="l00729"></a><span class="lineno">  729</span>&#160;    <span class="keywordtype">int</span> rankIsUpper; <span class="comment">// rank is in the upper half of an outer block</span></div>
<div class="line"><a name="l00730"></a><span class="lineno">  730</span>&#160;    <span class="keywordtype">int</span> pairRank; <span class="comment">// rank of corresponding chunk</span></div>
<div class="line"><a name="l00731"></a><span class="lineno">  731</span>&#160; </div>
<div class="line"><a name="l00732"></a><span class="lineno">  732</span>&#160;    <span class="keywordtype">int</span> useLocalDataOnly = <a class="code" href="QuEST__cpu__distributed_8c.html#a076fe6125da4d6037b8bc4d912df4015">densityMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, </div>
<div class="line"><a name="l00733"></a><span class="lineno">  733</span>&#160;            qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>, targetQubit);</div>
<div class="line"><a name="l00734"></a><span class="lineno">  734</span>&#160; </div>
<div class="line"><a name="l00735"></a><span class="lineno">  735</span>&#160;    <span class="keywordflow">if</span> (useLocalDataOnly){</div>
<div class="line"><a name="l00736"></a><span class="lineno">  736</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#ab124a3a9956046bf9c0e1e3ae9171f42">densmatr_mixDampingLocal</a>(qureg, targetQubit, damping);</div>
<div class="line"><a name="l00737"></a><span class="lineno">  737</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00738"></a><span class="lineno">  738</span>&#160;        <span class="comment">// pack data to send to my pair process into the first half of pairStateVec</span></div>
<div class="line"><a name="l00739"></a><span class="lineno">  739</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#a0eb14d48920ea469b0904ae63b47b589">compressPairVectorForSingleQubitDepolarise</a>(qureg, targetQubit);</div>
<div class="line"><a name="l00740"></a><span class="lineno">  740</span>&#160; </div>
<div class="line"><a name="l00741"></a><span class="lineno">  741</span>&#160;        rankIsUpper = <a class="code" href="QuEST__cpu__distributed_8c.html#aa3c2d644a2be7f0d3aa9f757527d306f">chunkIsUpperInOuterBlock</a>(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit, </div>
<div class="line"><a name="l00742"></a><span class="lineno">  742</span>&#160;                qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00743"></a><span class="lineno">  743</span>&#160;        pairRank = <a class="code" href="QuEST__cpu__distributed_8c.html#ae66dc6569c6e4008c33d6739db422c08">getChunkOuterBlockPairId</a>(rankIsUpper, qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, </div>
<div class="line"><a name="l00744"></a><span class="lineno">  744</span>&#160;                targetQubit, qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00745"></a><span class="lineno">  745</span>&#160; </div>
<div class="line"><a name="l00746"></a><span class="lineno">  746</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#a37dae401754961c9100b3c0907913c3e">exchangePairStateVectorHalves</a>(qureg, pairRank);</div>
<div class="line"><a name="l00747"></a><span class="lineno">  747</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#a8d9c19a3424f0ad89bfbfd920d65301d">densmatr_mixDampingDistributed</a>(qureg, targetQubit, damping);</div>
<div class="line"><a name="l00748"></a><span class="lineno">  748</span>&#160;    }</div>
<div class="line"><a name="l00749"></a><span class="lineno">  749</span>&#160; </div>
<div class="line"><a name="l00750"></a><span class="lineno">  750</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00236">chunkIsUpperInOuterBlock()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00543">compressPairVectorForSingleQubitDepolarise()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00363">densityMatrixBlockFitsInChunk()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l00300">densmatr_mixDampingDistributed()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l00174">densmatr_mixDampingLocal()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00509">exchangePairStateVectorHalves()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00314">getChunkOuterBlockPairId()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, and <a class="el" href="QuEST_8h_source.html#l00208">Qureg::numQubitsRepresented</a>.</p>

</div>
</div>
<a id="a398b60c4cb4fa2cf2ffc126de6c08da0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a398b60c4cb4fa2cf2ffc126de6c08da0">&#9670;&nbsp;</a></span>densmatr_mixDepolarising()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void densmatr_mixDepolarising </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>depolLevel</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00698">698</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00698"></a><span class="lineno">  698</span>&#160;                                                                              {</div>
<div class="line"><a name="l00699"></a><span class="lineno">  699</span>&#160;    <span class="keywordflow">if</span> (depolLevel == 0)</div>
<div class="line"><a name="l00700"></a><span class="lineno">  700</span>&#160;        <span class="keywordflow">return</span>;</div>
<div class="line"><a name="l00701"></a><span class="lineno">  701</span>&#160;    </div>
<div class="line"><a name="l00702"></a><span class="lineno">  702</span>&#160;    <span class="keywordtype">int</span> rankIsUpper; <span class="comment">// rank is in the upper half of an outer block</span></div>
<div class="line"><a name="l00703"></a><span class="lineno">  703</span>&#160;    <span class="keywordtype">int</span> pairRank; <span class="comment">// rank of corresponding chunk</span></div>
<div class="line"><a name="l00704"></a><span class="lineno">  704</span>&#160; </div>
<div class="line"><a name="l00705"></a><span class="lineno">  705</span>&#160;    <span class="keywordtype">int</span> useLocalDataOnly = <a class="code" href="QuEST__cpu__distributed_8c.html#a076fe6125da4d6037b8bc4d912df4015">densityMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, </div>
<div class="line"><a name="l00706"></a><span class="lineno">  706</span>&#160;            qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>, targetQubit);</div>
<div class="line"><a name="l00707"></a><span class="lineno">  707</span>&#160; </div>
<div class="line"><a name="l00708"></a><span class="lineno">  708</span>&#160;    <span class="keywordflow">if</span> (useLocalDataOnly){</div>
<div class="line"><a name="l00709"></a><span class="lineno">  709</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#ab750fb47da2fca9849c678c869e40e69">densmatr_mixDepolarisingLocal</a>(qureg, targetQubit, depolLevel);</div>
<div class="line"><a name="l00710"></a><span class="lineno">  710</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00711"></a><span class="lineno">  711</span>&#160;        <span class="comment">// pack data to send to my pair process into the first half of pairStateVec</span></div>
<div class="line"><a name="l00712"></a><span class="lineno">  712</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#a0eb14d48920ea469b0904ae63b47b589">compressPairVectorForSingleQubitDepolarise</a>(qureg, targetQubit);</div>
<div class="line"><a name="l00713"></a><span class="lineno">  713</span>&#160; </div>
<div class="line"><a name="l00714"></a><span class="lineno">  714</span>&#160;        rankIsUpper = <a class="code" href="QuEST__cpu__distributed_8c.html#aa3c2d644a2be7f0d3aa9f757527d306f">chunkIsUpperInOuterBlock</a>(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit, </div>
<div class="line"><a name="l00715"></a><span class="lineno">  715</span>&#160;                qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00716"></a><span class="lineno">  716</span>&#160;        pairRank = <a class="code" href="QuEST__cpu__distributed_8c.html#ae66dc6569c6e4008c33d6739db422c08">getChunkOuterBlockPairId</a>(rankIsUpper, qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, </div>
<div class="line"><a name="l00717"></a><span class="lineno">  717</span>&#160;                targetQubit, qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00718"></a><span class="lineno">  718</span>&#160; </div>
<div class="line"><a name="l00719"></a><span class="lineno">  719</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#a37dae401754961c9100b3c0907913c3e">exchangePairStateVectorHalves</a>(qureg, pairRank);</div>
<div class="line"><a name="l00720"></a><span class="lineno">  720</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#a88670d0e7cebe33f61c1dd98daa338b3">densmatr_mixDepolarisingDistributed</a>(qureg, targetQubit, depolLevel);</div>
<div class="line"><a name="l00721"></a><span class="lineno">  721</span>&#160;    }</div>
<div class="line"><a name="l00722"></a><span class="lineno">  722</span>&#160; </div>
<div class="line"><a name="l00723"></a><span class="lineno">  723</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00236">chunkIsUpperInOuterBlock()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00543">compressPairVectorForSingleQubitDepolarise()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00363">densityMatrixBlockFitsInChunk()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l00224">densmatr_mixDepolarisingDistributed()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l00125">densmatr_mixDepolarisingLocal()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00509">exchangePairStateVectorHalves()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00314">getChunkOuterBlockPairId()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, and <a class="el" href="QuEST_8h_source.html#l00208">Qureg::numQubitsRepresented</a>.</p>

</div>
</div>
<a id="a43afa97e300b87bce7f3eb1213eb05f6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a43afa97e300b87bce7f3eb1213eb05f6">&#9670;&nbsp;</a></span>densmatr_mixTwoQubitDepolarising()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void densmatr_mixTwoQubitDepolarising </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>qubit1</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>qubit2</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>depolLevel</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00752">752</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00752"></a><span class="lineno">  752</span>&#160;                                                                                            {</div>
<div class="line"><a name="l00753"></a><span class="lineno">  753</span>&#160;    <span class="keywordflow">if</span> (depolLevel == 0)</div>
<div class="line"><a name="l00754"></a><span class="lineno">  754</span>&#160;        <span class="keywordflow">return</span>;</div>
<div class="line"><a name="l00755"></a><span class="lineno">  755</span>&#160;    <span class="keywordtype">int</span> rankIsUpperBiggerQubit, rankIsUpperSmallerQubit;</div>
<div class="line"><a name="l00756"></a><span class="lineno">  756</span>&#160;    <span class="keywordtype">int</span> pairRank; <span class="comment">// rank of corresponding chunk</span></div>
<div class="line"><a name="l00757"></a><span class="lineno">  757</span>&#160;    <span class="keywordtype">int</span> biggerQubit, smallerQubit;</div>
<div class="line"><a name="l00758"></a><span class="lineno">  758</span>&#160; </div>
<div class="line"><a name="l00759"></a><span class="lineno">  759</span>&#160;    <a class="code" href="QuEST__internal_8h.html#a623e577b7230f3c8dc202be6185b4289">densmatr_mixTwoQubitDephasing</a>(qureg, qubit1, qubit2, depolLevel);</div>
<div class="line"><a name="l00760"></a><span class="lineno">  760</span>&#160;    </div>
<div class="line"><a name="l00761"></a><span class="lineno">  761</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> eta = 2/depolLevel;</div>
<div class="line"><a name="l00762"></a><span class="lineno">  762</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> delta = eta - 1 - sqrt( (eta-1)*(eta-1) - 1 ); </div>
<div class="line"><a name="l00763"></a><span class="lineno">  763</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> gamma = 1+delta;</div>
<div class="line"><a name="l00764"></a><span class="lineno">  764</span>&#160;    gamma = 1/(gamma*gamma*gamma);</div>
<div class="line"><a name="l00765"></a><span class="lineno">  765</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> GAMMA_PARTS_1_OR_2 = 1.0;</div>
<div class="line"><a name="l00766"></a><span class="lineno">  766</span>&#160;    <span class="comment">// TODO -- test delta too small</span></div>
<div class="line"><a name="l00767"></a><span class="lineno">  767</span>&#160;    <span class="comment">/*   </span></div>
<div class="line"><a name="l00768"></a><span class="lineno">  768</span>&#160;<span class="comment">    if (fabs(4*delta*(1+delta)*gamma-depolLevel)&gt;1e-5){</span></div>
<div class="line"><a name="l00769"></a><span class="lineno">  769</span>&#160;<span class="comment">        printf(&quot;Numerical error in delta; for small error rates try Taylor expansion.\n&quot;);</span></div>
<div class="line"><a name="l00770"></a><span class="lineno">  770</span>&#160;<span class="comment">        exit(1);</span></div>
<div class="line"><a name="l00771"></a><span class="lineno">  771</span>&#160;<span class="comment">    }</span></div>
<div class="line"><a name="l00772"></a><span class="lineno">  772</span>&#160;<span class="comment">    */</span></div>
<div class="line"><a name="l00773"></a><span class="lineno">  773</span>&#160;    </div>
<div class="line"><a name="l00774"></a><span class="lineno">  774</span>&#160;    biggerQubit = qubit1 &gt; qubit2 ? qubit1 : qubit2;</div>
<div class="line"><a name="l00775"></a><span class="lineno">  775</span>&#160;    smallerQubit = qubit1 &lt; qubit2 ? qubit1 : qubit2;</div>
<div class="line"><a name="l00776"></a><span class="lineno">  776</span>&#160;    <span class="keywordtype">int</span> useLocalDataOnlyBigQubit, useLocalDataOnlySmallQubit;</div>
<div class="line"><a name="l00777"></a><span class="lineno">  777</span>&#160; </div>
<div class="line"><a name="l00778"></a><span class="lineno">  778</span>&#160;    useLocalDataOnlyBigQubit = <a class="code" href="QuEST__cpu__distributed_8c.html#a076fe6125da4d6037b8bc4d912df4015">densityMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, </div>
<div class="line"><a name="l00779"></a><span class="lineno">  779</span>&#160;        qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>, biggerQubit);</div>
<div class="line"><a name="l00780"></a><span class="lineno">  780</span>&#160;    <span class="keywordflow">if</span> (useLocalDataOnlyBigQubit){</div>
<div class="line"><a name="l00781"></a><span class="lineno">  781</span>&#160;        <span class="comment">// does parts 1, 2 and 3 locally in one go</span></div>
<div class="line"><a name="l00782"></a><span class="lineno">  782</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#a3510f01d4d15dcc545564eb84c668cad">densmatr_mixTwoQubitDepolarisingLocal</a>(qureg, qubit1, qubit2, delta, gamma);</div>
<div class="line"><a name="l00783"></a><span class="lineno">  783</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00784"></a><span class="lineno">  784</span>&#160;        useLocalDataOnlySmallQubit = <a class="code" href="QuEST__cpu__distributed_8c.html#a076fe6125da4d6037b8bc4d912df4015">densityMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, </div>
<div class="line"><a name="l00785"></a><span class="lineno">  785</span>&#160;            qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>, smallerQubit);</div>
<div class="line"><a name="l00786"></a><span class="lineno">  786</span>&#160;        <span class="keywordflow">if</span> (useLocalDataOnlySmallQubit){</div>
<div class="line"><a name="l00787"></a><span class="lineno">  787</span>&#160;            <span class="comment">// do part 1 locally</span></div>
<div class="line"><a name="l00788"></a><span class="lineno">  788</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#ae90f82418e0aa67218d733dbbc681998">densmatr_mixTwoQubitDepolarisingLocalPart1</a>(qureg, smallerQubit, biggerQubit, delta);</div>
<div class="line"><a name="l00789"></a><span class="lineno">  789</span>&#160;            </div>
<div class="line"><a name="l00790"></a><span class="lineno">  790</span>&#160;            <span class="comment">// do parts 2 and 3 distributed (if part 2 is distributed part 3 is also distributed)</span></div>
<div class="line"><a name="l00791"></a><span class="lineno">  791</span>&#160;            <span class="comment">// part 2 will be distributed and the value of the small qubit won&#39;t matter</span></div>
<div class="line"><a name="l00792"></a><span class="lineno">  792</span>&#160;            <a class="code" href="QuEST__cpu__distributed_8c.html#a373394db1bf71b0be63585c0e9a52abb">compressPairVectorForTwoQubitDepolarise</a>(qureg, smallerQubit, biggerQubit);</div>
<div class="line"><a name="l00793"></a><span class="lineno">  793</span>&#160;            rankIsUpperBiggerQubit = <a class="code" href="QuEST__cpu__distributed_8c.html#aa3c2d644a2be7f0d3aa9f757527d306f">chunkIsUpperInOuterBlock</a>(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, biggerQubit, </div>
<div class="line"><a name="l00794"></a><span class="lineno">  794</span>&#160;                    qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00795"></a><span class="lineno">  795</span>&#160;            pairRank = <a class="code" href="QuEST__cpu__distributed_8c.html#ae66dc6569c6e4008c33d6739db422c08">getChunkOuterBlockPairId</a>(rankIsUpperBiggerQubit, qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, </div>
<div class="line"><a name="l00796"></a><span class="lineno">  796</span>&#160;                    biggerQubit, qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00797"></a><span class="lineno">  797</span>&#160; </div>
<div class="line"><a name="l00798"></a><span class="lineno">  798</span>&#160;            <a class="code" href="QuEST__cpu__distributed_8c.html#a37dae401754961c9100b3c0907913c3e">exchangePairStateVectorHalves</a>(qureg, pairRank);</div>
<div class="line"><a name="l00799"></a><span class="lineno">  799</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#a2f76ec8f08e19bb8e1254aafb10e160e">densmatr_mixTwoQubitDepolarisingDistributed</a>(qureg, smallerQubit, biggerQubit, delta, GAMMA_PARTS_1_OR_2);</div>
<div class="line"><a name="l00800"></a><span class="lineno">  800</span>&#160;            </div>
<div class="line"><a name="l00801"></a><span class="lineno">  801</span>&#160;            <span class="comment">// part 3 will be distributed but involve rearranging for the smaller qubit</span></div>
<div class="line"><a name="l00802"></a><span class="lineno">  802</span>&#160;            <a class="code" href="QuEST__cpu__distributed_8c.html#a373394db1bf71b0be63585c0e9a52abb">compressPairVectorForTwoQubitDepolarise</a>(qureg, smallerQubit, biggerQubit);</div>
<div class="line"><a name="l00803"></a><span class="lineno">  803</span>&#160;            rankIsUpperBiggerQubit = <a class="code" href="QuEST__cpu__distributed_8c.html#aa3c2d644a2be7f0d3aa9f757527d306f">chunkIsUpperInOuterBlock</a>(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, biggerQubit, </div>
<div class="line"><a name="l00804"></a><span class="lineno">  804</span>&#160;                    qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00805"></a><span class="lineno">  805</span>&#160;            pairRank = <a class="code" href="QuEST__cpu__distributed_8c.html#ae66dc6569c6e4008c33d6739db422c08">getChunkOuterBlockPairId</a>(rankIsUpperBiggerQubit, qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, </div>
<div class="line"><a name="l00806"></a><span class="lineno">  806</span>&#160;                    biggerQubit, qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00807"></a><span class="lineno">  807</span>&#160; </div>
<div class="line"><a name="l00808"></a><span class="lineno">  808</span>&#160;            <a class="code" href="QuEST__cpu__distributed_8c.html#a37dae401754961c9100b3c0907913c3e">exchangePairStateVectorHalves</a>(qureg, pairRank);</div>
<div class="line"><a name="l00809"></a><span class="lineno">  809</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#acabdfbd3184d3ab3bded61e24142b800">densmatr_mixTwoQubitDepolarisingQ1LocalQ2DistributedPart3</a>(qureg, smallerQubit, biggerQubit, delta, gamma);</div>
<div class="line"><a name="l00810"></a><span class="lineno">  810</span>&#160;        } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00811"></a><span class="lineno">  811</span>&#160;            <span class="comment">// do part 1, 2 and 3 distributed</span></div>
<div class="line"><a name="l00812"></a><span class="lineno">  812</span>&#160;            <span class="comment">// part 1</span></div>
<div class="line"><a name="l00813"></a><span class="lineno">  813</span>&#160;            <a class="code" href="QuEST__cpu__distributed_8c.html#a373394db1bf71b0be63585c0e9a52abb">compressPairVectorForTwoQubitDepolarise</a>(qureg, smallerQubit, biggerQubit);</div>
<div class="line"><a name="l00814"></a><span class="lineno">  814</span>&#160;            rankIsUpperSmallerQubit = <a class="code" href="QuEST__cpu__distributed_8c.html#aa3c2d644a2be7f0d3aa9f757527d306f">chunkIsUpperInOuterBlock</a>(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, smallerQubit, </div>
<div class="line"><a name="l00815"></a><span class="lineno">  815</span>&#160;                    qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00816"></a><span class="lineno">  816</span>&#160;            pairRank = <a class="code" href="QuEST__cpu__distributed_8c.html#ae66dc6569c6e4008c33d6739db422c08">getChunkOuterBlockPairId</a>(rankIsUpperSmallerQubit, qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, </div>
<div class="line"><a name="l00817"></a><span class="lineno">  817</span>&#160;                    smallerQubit, qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00818"></a><span class="lineno">  818</span>&#160; </div>
<div class="line"><a name="l00819"></a><span class="lineno">  819</span>&#160;            <a class="code" href="QuEST__cpu__distributed_8c.html#a37dae401754961c9100b3c0907913c3e">exchangePairStateVectorHalves</a>(qureg, pairRank);</div>
<div class="line"><a name="l00820"></a><span class="lineno">  820</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#a2f76ec8f08e19bb8e1254aafb10e160e">densmatr_mixTwoQubitDepolarisingDistributed</a>(qureg, smallerQubit, biggerQubit, delta, GAMMA_PARTS_1_OR_2);</div>
<div class="line"><a name="l00821"></a><span class="lineno">  821</span>&#160; </div>
<div class="line"><a name="l00822"></a><span class="lineno">  822</span>&#160;            <span class="comment">// part 2</span></div>
<div class="line"><a name="l00823"></a><span class="lineno">  823</span>&#160;            <a class="code" href="QuEST__cpu__distributed_8c.html#a373394db1bf71b0be63585c0e9a52abb">compressPairVectorForTwoQubitDepolarise</a>(qureg, smallerQubit, biggerQubit);</div>
<div class="line"><a name="l00824"></a><span class="lineno">  824</span>&#160;            rankIsUpperBiggerQubit = <a class="code" href="QuEST__cpu__distributed_8c.html#aa3c2d644a2be7f0d3aa9f757527d306f">chunkIsUpperInOuterBlock</a>(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, biggerQubit, </div>
<div class="line"><a name="l00825"></a><span class="lineno">  825</span>&#160;                    qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00826"></a><span class="lineno">  826</span>&#160;            pairRank = <a class="code" href="QuEST__cpu__distributed_8c.html#ae66dc6569c6e4008c33d6739db422c08">getChunkOuterBlockPairId</a>(rankIsUpperBiggerQubit, qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, </div>
<div class="line"><a name="l00827"></a><span class="lineno">  827</span>&#160;                    biggerQubit, qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00828"></a><span class="lineno">  828</span>&#160; </div>
<div class="line"><a name="l00829"></a><span class="lineno">  829</span>&#160;            <a class="code" href="QuEST__cpu__distributed_8c.html#a37dae401754961c9100b3c0907913c3e">exchangePairStateVectorHalves</a>(qureg, pairRank);</div>
<div class="line"><a name="l00830"></a><span class="lineno">  830</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#a2f76ec8f08e19bb8e1254aafb10e160e">densmatr_mixTwoQubitDepolarisingDistributed</a>(qureg, smallerQubit, biggerQubit, delta, GAMMA_PARTS_1_OR_2);</div>
<div class="line"><a name="l00831"></a><span class="lineno">  831</span>&#160; </div>
<div class="line"><a name="l00832"></a><span class="lineno">  832</span>&#160;            <span class="comment">// part 3</span></div>
<div class="line"><a name="l00833"></a><span class="lineno">  833</span>&#160;            <a class="code" href="QuEST__cpu__distributed_8c.html#a373394db1bf71b0be63585c0e9a52abb">compressPairVectorForTwoQubitDepolarise</a>(qureg, smallerQubit, biggerQubit);</div>
<div class="line"><a name="l00834"></a><span class="lineno">  834</span>&#160;            pairRank = <a class="code" href="QuEST__cpu__distributed_8c.html#ab1ec7f241b68b079c8e316d190af49ce">getChunkOuterBlockPairIdForPart3</a>(rankIsUpperSmallerQubit, rankIsUpperBiggerQubit, </div>
<div class="line"><a name="l00835"></a><span class="lineno">  835</span>&#160;                    qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, smallerQubit, biggerQubit, qureg.<a class="code" href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">numQubitsRepresented</a>);</div>
<div class="line"><a name="l00836"></a><span class="lineno">  836</span>&#160;            <a class="code" href="QuEST__cpu__distributed_8c.html#a37dae401754961c9100b3c0907913c3e">exchangePairStateVectorHalves</a>(qureg, pairRank);</div>
<div class="line"><a name="l00837"></a><span class="lineno">  837</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#a2f76ec8f08e19bb8e1254aafb10e160e">densmatr_mixTwoQubitDepolarisingDistributed</a>(qureg, smallerQubit, biggerQubit, delta, gamma);</div>
<div class="line"><a name="l00838"></a><span class="lineno">  838</span>&#160; </div>
<div class="line"><a name="l00839"></a><span class="lineno">  839</span>&#160;        }</div>
<div class="line"><a name="l00840"></a><span class="lineno">  840</span>&#160;    }</div>
<div class="line"><a name="l00841"></a><span class="lineno">  841</span>&#160; </div>
<div class="line"><a name="l00842"></a><span class="lineno">  842</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00236">chunkIsUpperInOuterBlock()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00610">compressPairVectorForTwoQubitDepolarise()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00363">densityMatrixBlockFitsInChunk()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l00084">densmatr_mixTwoQubitDephasing()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l00541">densmatr_mixTwoQubitDepolarisingDistributed()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l00387">densmatr_mixTwoQubitDepolarisingLocal()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l00488">densmatr_mixTwoQubitDepolarisingLocalPart1()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l00632">densmatr_mixTwoQubitDepolarisingQ1LocalQ2DistributedPart3()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00509">exchangePairStateVectorHalves()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00314">getChunkOuterBlockPairId()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00325">getChunkOuterBlockPairIdForPart3()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00208">Qureg::numQubitsRepresented</a>, and <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>.</p>

</div>
</div>
<a id="a37dae401754961c9100b3c0907913c3e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a37dae401754961c9100b3c0907913c3e">&#9670;&nbsp;</a></span>exchangePairStateVectorHalves()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void exchangePairStateVectorHalves </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>pairRank</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00509">509</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00509"></a><span class="lineno">  509</span>&#160;                                                             {</div>
<div class="line"><a name="l00510"></a><span class="lineno">  510</span>&#160;    <span class="comment">// MPI send/receive vars</span></div>
<div class="line"><a name="l00511"></a><span class="lineno">  511</span>&#160;    <span class="keywordtype">int</span> TAG=100;</div>
<div class="line"><a name="l00512"></a><span class="lineno">  512</span>&#160;    MPI_Status status;</div>
<div class="line"><a name="l00513"></a><span class="lineno">  513</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> numAmpsToSend = qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a> &gt;&gt; 1;</div>
<div class="line"><a name="l00514"></a><span class="lineno">  514</span>&#160; </div>
<div class="line"><a name="l00515"></a><span class="lineno">  515</span>&#160;    <span class="comment">// Multiple messages are required as MPI uses int rather than long long int for count</span></div>
<div class="line"><a name="l00516"></a><span class="lineno">  516</span>&#160;    <span class="comment">// For openmpi, messages are further restricted to 2GB in size -- do this for all cases</span></div>
<div class="line"><a name="l00517"></a><span class="lineno">  517</span>&#160;    <span class="comment">// to be safe</span></div>
<div class="line"><a name="l00518"></a><span class="lineno">  518</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> maxMessageCount = MPI_MAX_AMPS_IN_MSG;</div>
<div class="line"><a name="l00519"></a><span class="lineno">  519</span>&#160;    <span class="keywordflow">if</span> (numAmpsToSend &lt; maxMessageCount) </div>
<div class="line"><a name="l00520"></a><span class="lineno">  520</span>&#160;        maxMessageCount = numAmpsToSend;</div>
<div class="line"><a name="l00521"></a><span class="lineno">  521</span>&#160;    </div>
<div class="line"><a name="l00522"></a><span class="lineno">  522</span>&#160;    <span class="comment">// safely assume MPI_MAX... = 2^n, so division always exact</span></div>
<div class="line"><a name="l00523"></a><span class="lineno">  523</span>&#160;    <span class="keywordtype">int</span> numMessages = numAmpsToSend/maxMessageCount;</div>
<div class="line"><a name="l00524"></a><span class="lineno">  524</span>&#160;    <span class="keywordtype">int</span> i;</div>
<div class="line"><a name="l00525"></a><span class="lineno">  525</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> offset;</div>
<div class="line"><a name="l00526"></a><span class="lineno">  526</span>&#160;    <span class="comment">// send the bottom half of my state vector to the top half of pairRank&#39;s qureg.pairStateVec</span></div>
<div class="line"><a name="l00527"></a><span class="lineno">  527</span>&#160;    <span class="comment">// receive pairRank&#39;s state vector into the top of qureg.pairStateVec</span></div>
<div class="line"><a name="l00528"></a><span class="lineno">  528</span>&#160;    <span class="keywordflow">for</span> (i=0; i&lt;numMessages; i++){</div>
<div class="line"><a name="l00529"></a><span class="lineno">  529</span>&#160;        offset = i*maxMessageCount;</div>
<div class="line"><a name="l00530"></a><span class="lineno">  530</span>&#160;        MPI_Sendrecv(&amp;qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.real[offset+numAmpsToSend], maxMessageCount, </div>
<div class="line"><a name="l00531"></a><span class="lineno">  531</span>&#160;                MPI_QuEST_REAL, pairRank, TAG,</div>
<div class="line"><a name="l00532"></a><span class="lineno">  532</span>&#160;                &amp;qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.real[offset], maxMessageCount, MPI_QuEST_REAL,</div>
<div class="line"><a name="l00533"></a><span class="lineno">  533</span>&#160;                pairRank, TAG, MPI_COMM_WORLD, &amp;status);</div>
<div class="line"><a name="l00534"></a><span class="lineno">  534</span>&#160;        <span class="comment">//printf(&quot;rank: %d err: %d\n&quot;, qureg.rank, err);</span></div>
<div class="line"><a name="l00535"></a><span class="lineno">  535</span>&#160;        MPI_Sendrecv(&amp;qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.imag[offset+numAmpsToSend], maxMessageCount, </div>
<div class="line"><a name="l00536"></a><span class="lineno">  536</span>&#160;                MPI_QuEST_REAL, pairRank, TAG,</div>
<div class="line"><a name="l00537"></a><span class="lineno">  537</span>&#160;                &amp;qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.imag[offset], maxMessageCount, MPI_QuEST_REAL,</div>
<div class="line"><a name="l00538"></a><span class="lineno">  538</span>&#160;                pairRank, TAG, MPI_COMM_WORLD, &amp;status);</div>
<div class="line"><a name="l00539"></a><span class="lineno">  539</span>&#160;    }</div>
<div class="line"><a name="l00540"></a><span class="lineno">  540</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, and <a class="el" href="QuEST_8h_source.html#l00224">Qureg::pairStateVec</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00725">densmatr_mixDamping()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00698">densmatr_mixDepolarising()</a>, and <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00752">densmatr_mixTwoQubitDepolarising()</a>.</p>

</div>
</div>
<a id="ae01c3eb75fd32de1a7e1dbc7a33a21e3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae01c3eb75fd32de1a7e1dbc7a33a21e3">&#9670;&nbsp;</a></span>exchangeStateVectors()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void exchangeStateVectors </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>pairRank</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00479">479</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00479"></a><span class="lineno">  479</span>&#160;                                                    {</div>
<div class="line"><a name="l00480"></a><span class="lineno">  480</span>&#160;    <span class="comment">// MPI send/receive vars</span></div>
<div class="line"><a name="l00481"></a><span class="lineno">  481</span>&#160;    <span class="keywordtype">int</span> TAG=100;</div>
<div class="line"><a name="l00482"></a><span class="lineno">  482</span>&#160;    MPI_Status status;</div>
<div class="line"><a name="l00483"></a><span class="lineno">  483</span>&#160; </div>
<div class="line"><a name="l00484"></a><span class="lineno">  484</span>&#160;    <span class="comment">// Multiple messages are required as MPI uses int rather than long long int for count</span></div>
<div class="line"><a name="l00485"></a><span class="lineno">  485</span>&#160;    <span class="comment">// For openmpi, messages are further restricted to 2GB in size -- do this for all cases</span></div>
<div class="line"><a name="l00486"></a><span class="lineno">  486</span>&#160;    <span class="comment">// to be safe</span></div>
<div class="line"><a name="l00487"></a><span class="lineno">  487</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> maxMessageCount = MPI_MAX_AMPS_IN_MSG;</div>
<div class="line"><a name="l00488"></a><span class="lineno">  488</span>&#160;    <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a> &lt; maxMessageCount) </div>
<div class="line"><a name="l00489"></a><span class="lineno">  489</span>&#160;        maxMessageCount = qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l00490"></a><span class="lineno">  490</span>&#160;    </div>
<div class="line"><a name="l00491"></a><span class="lineno">  491</span>&#160;    <span class="comment">// safely assume MPI_MAX... = 2^n, so division always exact</span></div>
<div class="line"><a name="l00492"></a><span class="lineno">  492</span>&#160;    <span class="keywordtype">int</span> numMessages = qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>/maxMessageCount;</div>
<div class="line"><a name="l00493"></a><span class="lineno">  493</span>&#160;    <span class="keywordtype">int</span> i;</div>
<div class="line"><a name="l00494"></a><span class="lineno">  494</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> offset;</div>
<div class="line"><a name="l00495"></a><span class="lineno">  495</span>&#160;    <span class="comment">// send my state vector to pairRank&#39;s qureg.pairStateVec</span></div>
<div class="line"><a name="l00496"></a><span class="lineno">  496</span>&#160;    <span class="comment">// receive pairRank&#39;s state vector into qureg.pairStateVec</span></div>
<div class="line"><a name="l00497"></a><span class="lineno">  497</span>&#160;    <span class="keywordflow">for</span> (i=0; i&lt;numMessages; i++){</div>
<div class="line"><a name="l00498"></a><span class="lineno">  498</span>&#160;        offset = i*maxMessageCount;</div>
<div class="line"><a name="l00499"></a><span class="lineno">  499</span>&#160;        MPI_Sendrecv(&amp;qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real[offset], maxMessageCount, MPI_QuEST_REAL, pairRank, TAG,</div>
<div class="line"><a name="l00500"></a><span class="lineno">  500</span>&#160;                &amp;qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.real[offset], maxMessageCount, MPI_QuEST_REAL,</div>
<div class="line"><a name="l00501"></a><span class="lineno">  501</span>&#160;                pairRank, TAG, MPI_COMM_WORLD, &amp;status);</div>
<div class="line"><a name="l00502"></a><span class="lineno">  502</span>&#160;        <span class="comment">//printf(&quot;rank: %d err: %d\n&quot;, qureg.rank, err);</span></div>
<div class="line"><a name="l00503"></a><span class="lineno">  503</span>&#160;        MPI_Sendrecv(&amp;qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag[offset], maxMessageCount, MPI_QuEST_REAL, pairRank, TAG,</div>
<div class="line"><a name="l00504"></a><span class="lineno">  504</span>&#160;                &amp;qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>.imag[offset], maxMessageCount, MPI_QuEST_REAL,</div>
<div class="line"><a name="l00505"></a><span class="lineno">  505</span>&#160;                pairRank, TAG, MPI_COMM_WORLD, &amp;status);</div>
<div class="line"><a name="l00506"></a><span class="lineno">  506</span>&#160;    }</div>
<div class="line"><a name="l00507"></a><span class="lineno">  507</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00224">Qureg::pairStateVec</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00844">statevec_compactUnitary()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00920">statevec_controlledCompactUnitary()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01061">statevec_controlledNot()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01140">statevec_controlledPauliY()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01173">statevec_controlledPauliYConj()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00958">statevec_controlledUnitary()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01206">statevec_hadamard()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00997">statevec_multiControlledUnitary()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01034">statevec_pauliX()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01090">statevec_pauliY()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01115">statevec_pauliYConj()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01354">statevec_swapQubitAmps()</a>, and <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00881">statevec_unitary()</a>.</p>

</div>
</div>
<a id="a28be36627b2dd9a0da63dd6f60121b06"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a28be36627b2dd9a0da63dd6f60121b06">&#9670;&nbsp;</a></span>getChunkIdFromIndex()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">int getChunkIdFromIndex </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long long int&#160;</td>
          <td class="paramname"><em>index</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00194">194</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00194"></a><span class="lineno">  194</span>&#160;                                                         {</div>
<div class="line"><a name="l00195"></a><span class="lineno">  195</span>&#160;    <span class="keywordflow">return</span> index/qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>; <span class="comment">// this is numAmpsPerChunk</span></div>
<div class="line"><a name="l00196"></a><span class="lineno">  196</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00208">statevec_getImagAmp()</a>, and <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00198">statevec_getRealAmp()</a>.</p>

</div>
</div>
<a id="ae66dc6569c6e4008c33d6739db422c08"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae66dc6569c6e4008c33d6739db422c08">&#9670;&nbsp;</a></span>getChunkOuterBlockPairId()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static int getChunkOuterBlockPairId </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>chunkIsUpper</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>chunkId</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long long int&#160;</td>
          <td class="paramname"><em>chunkSize</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numQubits</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00314">314</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00315"></a><span class="lineno">  315</span>&#160;{</div>
<div class="line"><a name="l00316"></a><span class="lineno">  316</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> sizeOuterHalfBlock = 1LL &lt;&lt; (targetQubit+numQubits);</div>
<div class="line"><a name="l00317"></a><span class="lineno">  317</span>&#160;    <span class="keywordtype">int</span> chunksPerOuterHalfBlock = sizeOuterHalfBlock/chunkSize;</div>
<div class="line"><a name="l00318"></a><span class="lineno">  318</span>&#160;    <span class="keywordflow">if</span> (<a class="code" href="QuEST__cpu__distributed_8c.html#a0552889d6f57d9e0ed8b209bf426482d">chunkIsUpper</a>){</div>
<div class="line"><a name="l00319"></a><span class="lineno">  319</span>&#160;        <span class="keywordflow">return</span> chunkId + chunksPerOuterHalfBlock;</div>
<div class="line"><a name="l00320"></a><span class="lineno">  320</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00321"></a><span class="lineno">  321</span>&#160;        <span class="keywordflow">return</span> chunkId - chunksPerOuterHalfBlock;</div>
<div class="line"><a name="l00322"></a><span class="lineno">  322</span>&#160;    }</div>
<div class="line"><a name="l00323"></a><span class="lineno">  323</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00227">chunkIsUpper()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00725">densmatr_mixDamping()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00698">densmatr_mixDepolarising()</a>, and <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00752">densmatr_mixTwoQubitDepolarising()</a>.</p>

</div>
</div>
<a id="ab1ec7f241b68b079c8e316d190af49ce"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab1ec7f241b68b079c8e316d190af49ce">&#9670;&nbsp;</a></span>getChunkOuterBlockPairIdForPart3()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static int getChunkOuterBlockPairIdForPart3 </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>chunkIsUpperSmallerQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>chunkIsUpperBiggerQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>chunkId</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long long int&#160;</td>
          <td class="paramname"><em>chunkSize</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>smallerQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>biggerQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numQubits</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00325">325</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00327"></a><span class="lineno">  327</span>&#160;{</div>
<div class="line"><a name="l00328"></a><span class="lineno">  328</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> sizeOuterHalfBlockBiggerQubit = 1LL &lt;&lt; (biggerQubit+numQubits);</div>
<div class="line"><a name="l00329"></a><span class="lineno">  329</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> sizeOuterHalfBlockSmallerQubit = 1LL &lt;&lt; (smallerQubit+numQubits);</div>
<div class="line"><a name="l00330"></a><span class="lineno">  330</span>&#160;    <span class="keywordtype">int</span> chunksPerOuterHalfBlockSmallerQubit = sizeOuterHalfBlockSmallerQubit/chunkSize;</div>
<div class="line"><a name="l00331"></a><span class="lineno">  331</span>&#160;    <span class="keywordtype">int</span> chunksPerOuterHalfBlockBiggerQubit = sizeOuterHalfBlockBiggerQubit/chunkSize;</div>
<div class="line"><a name="l00332"></a><span class="lineno">  332</span>&#160;    <span class="keywordtype">int</span> rank;</div>
<div class="line"><a name="l00333"></a><span class="lineno">  333</span>&#160;    <span class="keywordflow">if</span> (chunkIsUpperBiggerQubit){</div>
<div class="line"><a name="l00334"></a><span class="lineno">  334</span>&#160;        rank = chunkId + chunksPerOuterHalfBlockBiggerQubit;</div>
<div class="line"><a name="l00335"></a><span class="lineno">  335</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00336"></a><span class="lineno">  336</span>&#160;        rank = chunkId - chunksPerOuterHalfBlockBiggerQubit;</div>
<div class="line"><a name="l00337"></a><span class="lineno">  337</span>&#160;    }</div>
<div class="line"><a name="l00338"></a><span class="lineno">  338</span>&#160; </div>
<div class="line"><a name="l00339"></a><span class="lineno">  339</span>&#160;    <span class="keywordflow">if</span> (chunkIsUpperSmallerQubit){</div>
<div class="line"><a name="l00340"></a><span class="lineno">  340</span>&#160;        rank = rank + chunksPerOuterHalfBlockSmallerQubit;</div>
<div class="line"><a name="l00341"></a><span class="lineno">  341</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00342"></a><span class="lineno">  342</span>&#160;        rank = rank - chunksPerOuterHalfBlockSmallerQubit;</div>
<div class="line"><a name="l00343"></a><span class="lineno">  343</span>&#160;    }</div>
<div class="line"><a name="l00344"></a><span class="lineno">  344</span>&#160; </div>
<div class="line"><a name="l00345"></a><span class="lineno">  345</span>&#160;    <span class="keywordflow">return</span> rank;</div>
<div class="line"><a name="l00346"></a><span class="lineno">  346</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">Referenced by <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00752">densmatr_mixTwoQubitDepolarising()</a>.</p>

</div>
</div>
<a id="a7dba097f23f5d48dfdc9f3250444e2e4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a7dba097f23f5d48dfdc9f3250444e2e4">&#9670;&nbsp;</a></span>getChunkPairId()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static int getChunkPairId </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>chunkIsUpper</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>chunkId</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long long int&#160;</td>
          <td class="paramname"><em>chunkSize</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>get position of corresponding chunk, holding values required to update values in my chunk (with chunkId) when rotating targetQubit. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">chunkIsUpper</td><td>1: chunk is in upper half of block, 0: chunk is in lower half </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">chunkId</td><td>id of chunk in state vector </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">chunkSize</td><td>number of amps in chunk </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">targetQubit</td><td>qubit being rotated </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>chunkId of chunk required to rotate targetQubit </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00303">303</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00304"></a><span class="lineno">  304</span>&#160;{</div>
<div class="line"><a name="l00305"></a><span class="lineno">  305</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> sizeHalfBlock = 1LL &lt;&lt; (targetQubit);</div>
<div class="line"><a name="l00306"></a><span class="lineno">  306</span>&#160;    <span class="keywordtype">int</span> chunksPerHalfBlock = sizeHalfBlock/chunkSize;</div>
<div class="line"><a name="l00307"></a><span class="lineno">  307</span>&#160;    <span class="keywordflow">if</span> (<a class="code" href="QuEST__cpu__distributed_8c.html#a0552889d6f57d9e0ed8b209bf426482d">chunkIsUpper</a>){</div>
<div class="line"><a name="l00308"></a><span class="lineno">  308</span>&#160;        <span class="keywordflow">return</span> chunkId + chunksPerHalfBlock;</div>
<div class="line"><a name="l00309"></a><span class="lineno">  309</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00310"></a><span class="lineno">  310</span>&#160;        <span class="keywordflow">return</span> chunkId - chunksPerHalfBlock;</div>
<div class="line"><a name="l00311"></a><span class="lineno">  311</span>&#160;    }</div>
<div class="line"><a name="l00312"></a><span class="lineno">  312</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00227">chunkIsUpper()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00844">statevec_compactUnitary()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00920">statevec_controlledCompactUnitary()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01061">statevec_controlledNot()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01140">statevec_controlledPauliY()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01173">statevec_controlledPauliYConj()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00958">statevec_controlledUnitary()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01206">statevec_hadamard()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00997">statevec_multiControlledUnitary()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01034">statevec_pauliX()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01090">statevec_pauliY()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01115">statevec_pauliYConj()</a>, and <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00881">statevec_unitary()</a>.</p>

</div>
</div>
<a id="a4f243eb101c8e63f16cfd50300364cb7"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a4f243eb101c8e63f16cfd50300364cb7">&#9670;&nbsp;</a></span>getGlobalIndOfOddParityInChunk()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">long long int getGlobalIndOfOddParityInChunk </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>qb1</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>qb2</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>returns -1 if this node contains no amplitudes where qb1 and qb2 have opposite parity, otherwise returns the global index of one of such contained amplitudes (not necessarily the first) </p>

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01335">1335</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01335"></a><span class="lineno"> 1335</span>&#160;                                                                            {</div>
<div class="line"><a name="l01336"></a><span class="lineno"> 1336</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> chunkStartInd = qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a> * qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>;</div>
<div class="line"><a name="l01337"></a><span class="lineno"> 1337</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> chunkEndInd = chunkStartInd + qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>; <span class="comment">// exclusive</span></div>
<div class="line"><a name="l01338"></a><span class="lineno"> 1338</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> oddParityInd;</div>
<div class="line"><a name="l01339"></a><span class="lineno"> 1339</span>&#160;    </div>
<div class="line"><a name="l01340"></a><span class="lineno"> 1340</span>&#160;    <span class="keywordflow">if</span> (<a class="code" href="QuEST__gpu_8cu.html#aec1852e1a8e70d3690919ce8ab551ba0">extractBit</a>(qb1, chunkStartInd) != <a class="code" href="QuEST__gpu_8cu.html#aec1852e1a8e70d3690919ce8ab551ba0">extractBit</a>(qb2, chunkStartInd))</div>
<div class="line"><a name="l01341"></a><span class="lineno"> 1341</span>&#160;        <span class="keywordflow">return</span> chunkStartInd;</div>
<div class="line"><a name="l01342"></a><span class="lineno"> 1342</span>&#160;    </div>
<div class="line"><a name="l01343"></a><span class="lineno"> 1343</span>&#160;    oddParityInd = <a class="code" href="QuEST__gpu_8cu.html#ae1b7788cf504ec3d79de3855f97929c7">flipBit</a>(chunkStartInd, qb1);</div>
<div class="line"><a name="l01344"></a><span class="lineno"> 1344</span>&#160;    <span class="keywordflow">if</span> (oddParityInd &gt;= chunkStartInd &amp;&amp; oddParityInd &lt; chunkEndInd)</div>
<div class="line"><a name="l01345"></a><span class="lineno"> 1345</span>&#160;        <span class="keywordflow">return</span> oddParityInd;</div>
<div class="line"><a name="l01346"></a><span class="lineno"> 1346</span>&#160;        </div>
<div class="line"><a name="l01347"></a><span class="lineno"> 1347</span>&#160;    oddParityInd = <a class="code" href="QuEST__gpu_8cu.html#ae1b7788cf504ec3d79de3855f97929c7">flipBit</a>(chunkStartInd, qb2);</div>
<div class="line"><a name="l01348"></a><span class="lineno"> 1348</span>&#160;    <span class="keywordflow">if</span> (oddParityInd &gt;= chunkStartInd &amp;&amp; oddParityInd &lt; chunkEndInd)</div>
<div class="line"><a name="l01349"></a><span class="lineno"> 1349</span>&#160;        <span class="keywordflow">return</span> oddParityInd;</div>
<div class="line"><a name="l01350"></a><span class="lineno"> 1350</span>&#160;    </div>
<div class="line"><a name="l01351"></a><span class="lineno"> 1351</span>&#160;    <span class="keywordflow">return</span> -1;</div>
<div class="line"><a name="l01352"></a><span class="lineno"> 1352</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__gpu_8cu_source.html#l00082">extractBit()</a>, <a class="el" href="QuEST__gpu_8cu_source.html#l00095">flipBit()</a>, and <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01354">statevec_swapQubitAmps()</a>.</p>

</div>
</div>
<a id="adb4b0373425b282abed27742d0ce0872"></a>
<h2 class="memtitle"><span class="permalink"><a href="#adb4b0373425b282abed27742d0ce0872">&#9670;&nbsp;</a></span>getRotAngle()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static void getRotAngle </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>chunkIsUpper</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplex.html">Complex</a> *&#160;</td>
          <td class="paramname"><em>rot1</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplex.html">Complex</a> *&#160;</td>
          <td class="paramname"><em>rot2</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplex.html">Complex</a>&#160;</td>
          <td class="paramname"><em>alpha</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplex.html">Complex</a>&#160;</td>
          <td class="paramname"><em>beta</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Get rotation values for a given chunk. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">chunkIsUpper</td><td>1: chunk is in upper half of block, 0: chunk is in lower half</td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">rot1,rot2</td><td>rotation values to use, allocated for upper/lower such that <pre class="fragment">stateUpper = rot1 * stateUpper + conj(rot2)  * stateLower
</pre> or <pre class="fragment">stateLower = rot1 * stateUpper + conj(rot2)  * stateLower
</pre></td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">alpha,beta</td><td>initial rotation values </td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00258">258</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00259"></a><span class="lineno">  259</span>&#160;{</div>
<div class="line"><a name="l00260"></a><span class="lineno">  260</span>&#160;    <span class="keywordflow">if</span> (<a class="code" href="QuEST__cpu__distributed_8c.html#a0552889d6f57d9e0ed8b209bf426482d">chunkIsUpper</a>){</div>
<div class="line"><a name="l00261"></a><span class="lineno">  261</span>&#160;        *rot1=alpha;</div>
<div class="line"><a name="l00262"></a><span class="lineno">  262</span>&#160;        rot2-&gt;<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a>=-beta.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a>;</div>
<div class="line"><a name="l00263"></a><span class="lineno">  263</span>&#160;        rot2-&gt;<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a>=-beta.<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a>;</div>
<div class="line"><a name="l00264"></a><span class="lineno">  264</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00265"></a><span class="lineno">  265</span>&#160;        *rot1=beta;</div>
<div class="line"><a name="l00266"></a><span class="lineno">  266</span>&#160;        *rot2=alpha;</div>
<div class="line"><a name="l00267"></a><span class="lineno">  267</span>&#160;    }</div>
<div class="line"><a name="l00268"></a><span class="lineno">  268</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00227">chunkIsUpper()</a>, <a class="el" href="QuEST_8h_source.html#l00106">Complex::imag</a>, and <a class="el" href="QuEST_8h_source.html#l00105">Complex::real</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00844">statevec_compactUnitary()</a>, and <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00920">statevec_controlledCompactUnitary()</a>.</p>

</div>
</div>
<a id="a5c9b2f129bdffaaba9857f6eddecbb17"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5c9b2f129bdffaaba9857f6eddecbb17">&#9670;&nbsp;</a></span>getRotAngleFromUnitaryMatrix()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static void getRotAngleFromUnitaryMatrix </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>chunkIsUpper</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplex.html">Complex</a> *&#160;</td>
          <td class="paramname"><em>rot1</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplex.html">Complex</a> *&#160;</td>
          <td class="paramname"><em>rot2</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplexMatrix2.html">ComplexMatrix2</a>&#160;</td>
          <td class="paramname"><em>u</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Get rotation values for a given chunk given a unitary matrix. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">chunkIsUpper</td><td>1: chunk is in upper half of block, 0: chunk is in lower half</td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">rot1,rot2</td><td>rotation values to use, allocated for upper/lower such that <pre class="fragment">stateUpper = rot1 * stateUpper + conj(rot2)  * stateLower
</pre> or <pre class="fragment">stateLower = rot1 * stateUpper + conj(rot2)  * stateLower
</pre> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">u</td><td>unitary matrix operation </td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00283">283</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00284"></a><span class="lineno">  284</span>&#160;{</div>
<div class="line"><a name="l00285"></a><span class="lineno">  285</span>&#160;    <span class="keywordflow">if</span> (<a class="code" href="QuEST__cpu__distributed_8c.html#a0552889d6f57d9e0ed8b209bf426482d">chunkIsUpper</a>){</div>
<div class="line"><a name="l00286"></a><span class="lineno">  286</span>&#160;        *rot1=(<a class="code" href="structComplex.html">Complex</a>) {.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a>=u.<a class="code" href="structComplexMatrix2.html#a3ea98d545b67a190ee6abe936c72076f">real</a>[0][0], .imag=u.<a class="code" href="structComplexMatrix2.html#a3a2b60a9e00ccef054a6de3b9307c1be">imag</a>[0][0]};</div>
<div class="line"><a name="l00287"></a><span class="lineno">  287</span>&#160;        *rot2=(<a class="code" href="structComplex.html">Complex</a>) {.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a>=u.<a class="code" href="structComplexMatrix2.html#a3ea98d545b67a190ee6abe936c72076f">real</a>[0][1], .imag=u.<a class="code" href="structComplexMatrix2.html#a3a2b60a9e00ccef054a6de3b9307c1be">imag</a>[0][1]};</div>
<div class="line"><a name="l00288"></a><span class="lineno">  288</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00289"></a><span class="lineno">  289</span>&#160;        *rot1=(<a class="code" href="structComplex.html">Complex</a>) {.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a>=u.<a class="code" href="structComplexMatrix2.html#a3ea98d545b67a190ee6abe936c72076f">real</a>[1][0], .imag=u.<a class="code" href="structComplexMatrix2.html#a3a2b60a9e00ccef054a6de3b9307c1be">imag</a>[1][0]};</div>
<div class="line"><a name="l00290"></a><span class="lineno">  290</span>&#160;        *rot2=(<a class="code" href="structComplex.html">Complex</a>) {.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a>=u.<a class="code" href="structComplexMatrix2.html#a3ea98d545b67a190ee6abe936c72076f">real</a>[1][1], .imag=u.<a class="code" href="structComplexMatrix2.html#a3a2b60a9e00ccef054a6de3b9307c1be">imag</a>[1][1]};</div>
<div class="line"><a name="l00291"></a><span class="lineno">  291</span>&#160;    }</div>
<div class="line"><a name="l00292"></a><span class="lineno">  292</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00227">chunkIsUpper()</a>, <a class="el" href="QuEST_8h_source.html#l00117">ComplexMatrix2::imag</a>, <a class="el" href="QuEST_8h_source.html#l00105">Complex::real</a>, and <a class="el" href="QuEST_8h_source.html#l00116">ComplexMatrix2::real</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00958">statevec_controlledUnitary()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00997">statevec_multiControlledUnitary()</a>, and <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00881">statevec_unitary()</a>.</p>

</div>
</div>
<a id="a4d043bb0cee54a5f94faf3ffc34a6790"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a4d043bb0cee54a5f94faf3ffc34a6790">&#9670;&nbsp;</a></span>halfMatrixBlockFitsInChunk()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static int halfMatrixBlockFitsInChunk </td>
          <td>(</td>
          <td class="paramtype">long long int&#160;</td>
          <td class="paramname"><em>chunkSize</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>return whether the current qubit rotation will use blocks that fit within a single chunk. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">chunkSize</td><td>number of amps in chunk </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">targetQubit</td><td>qubit being rotated </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>1: one chunk fits in one block 0: chunk is larger than block fix &ndash; this should be renamed to matrixBlockFitsInChunk </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00356">356</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00357"></a><span class="lineno">  357</span>&#160;{</div>
<div class="line"><a name="l00358"></a><span class="lineno">  358</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> sizeHalfBlock = 1LL &lt;&lt; (targetQubit);</div>
<div class="line"><a name="l00359"></a><span class="lineno">  359</span>&#160;    <span class="keywordflow">if</span> (chunkSize &gt; sizeHalfBlock) <span class="keywordflow">return</span> 1;</div>
<div class="line"><a name="l00360"></a><span class="lineno">  360</span>&#160;    <span class="keywordflow">else</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><a name="l00361"></a><span class="lineno">  361</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">Referenced by <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01260">statevec_calcProbOfOutcome()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01298">statevec_collapseToKnownProbOutcome()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00844">statevec_compactUnitary()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00920">statevec_controlledCompactUnitary()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01061">statevec_controlledNot()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01140">statevec_controlledPauliY()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01173">statevec_controlledPauliYConj()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00958">statevec_controlledUnitary()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01206">statevec_hadamard()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01437">statevec_multiControlledMultiQubitUnitary()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01381">statevec_multiControlledTwoQubitUnitary()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00997">statevec_multiControlledUnitary()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01034">statevec_pauliX()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01090">statevec_pauliY()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01115">statevec_pauliYConj()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01354">statevec_swapQubitAmps()</a>, and <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00881">statevec_unitary()</a>.</p>

</div>
</div>
<a id="af0ea25f00987af4c53f17c9cca62ab41"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af0ea25f00987af4c53f17c9cca62ab41">&#9670;&nbsp;</a></span>isChunkToSkipInFindPZero()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static int isChunkToSkipInFindPZero </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>chunkId</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long long int&#160;</td>
          <td class="paramname"><em>chunkSize</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>measureQubit</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Find chunks to skip when calculating probability of qubit being zero. </p>
<p>When calculating probability of a bit q being zero, sum up 2^q values, then skip 2^q values, etc. This function finds if an entire chunk is in the range of values to be skipped</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">chunkId</td><td>id of chunk in state vector </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">chunkSize</td><td>number of amps in chunk </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">measureQubi</td><td>qubit being measured </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>int &ndash; 1: skip, 0: don't skip </dd></dl>

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01251">1251</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01252"></a><span class="lineno"> 1252</span>&#160;{</div>
<div class="line"><a name="l01253"></a><span class="lineno"> 1253</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> sizeHalfBlock = 1LL &lt;&lt; (measureQubit);</div>
<div class="line"><a name="l01254"></a><span class="lineno"> 1254</span>&#160;    <span class="keywordtype">int</span> numChunksToSkip = sizeHalfBlock/chunkSize;</div>
<div class="line"><a name="l01255"></a><span class="lineno"> 1255</span>&#160;    <span class="comment">// calculate probability by summing over numChunksToSkip, then skipping numChunksToSkip, etc</span></div>
<div class="line"><a name="l01256"></a><span class="lineno"> 1256</span>&#160;    <span class="keywordtype">int</span> bitToCheck = chunkId &amp; numChunksToSkip;</div>
<div class="line"><a name="l01257"></a><span class="lineno"> 1257</span>&#160;    <span class="keywordflow">return</span> bitToCheck;</div>
<div class="line"><a name="l01258"></a><span class="lineno"> 1258</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">Referenced by <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01260">statevec_calcProbOfOutcome()</a>, and <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01298">statevec_collapseToKnownProbOutcome()</a>.</p>

</div>
</div>
<a id="a0fb948ddab4ca210e523aa3c52639df4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a0fb948ddab4ca210e523aa3c52639df4">&#9670;&nbsp;</a></span>statevec_calcExpecDiagonalOp()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="structComplex.html">Complex</a> statevec_calcExpecDiagonalOp </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structDiagonalOp.html">DiagonalOp</a>&#160;</td>
          <td class="paramname"><em>op</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01523">1523</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01523"></a><span class="lineno"> 1523</span>&#160;                                                                 {</div>
<div class="line"><a name="l01524"></a><span class="lineno"> 1524</span>&#160; </div>
<div class="line"><a name="l01525"></a><span class="lineno"> 1525</span>&#160;    <a class="code" href="structComplex.html">Complex</a> localExpec = <a class="code" href="QuEST__cpu_8c.html#a16ccb485bcffb328bbd5b2af6977cead">statevec_calcExpecDiagonalOpLocal</a>(qureg, op);</div>
<div class="line"><a name="l01526"></a><span class="lineno"> 1526</span>&#160;    <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#aa3deb7163aab90a61e755a1f200f5413">numChunks</a> == 1)</div>
<div class="line"><a name="l01527"></a><span class="lineno"> 1527</span>&#160;        <span class="keywordflow">return</span> localExpec;</div>
<div class="line"><a name="l01528"></a><span class="lineno"> 1528</span>&#160;        </div>
<div class="line"><a name="l01529"></a><span class="lineno"> 1529</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> localReal = localExpec.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a>;</div>
<div class="line"><a name="l01530"></a><span class="lineno"> 1530</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> localImag = localExpec.<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a>;</div>
<div class="line"><a name="l01531"></a><span class="lineno"> 1531</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> globalReal, globalImag;</div>
<div class="line"><a name="l01532"></a><span class="lineno"> 1532</span>&#160;    MPI_Allreduce(&amp;localReal, &amp;globalReal, 1, MPI_QuEST_REAL, MPI_SUM, MPI_COMM_WORLD);</div>
<div class="line"><a name="l01533"></a><span class="lineno"> 1533</span>&#160;    MPI_Allreduce(&amp;localImag, &amp;globalImag, 1, MPI_QuEST_REAL, MPI_SUM, MPI_COMM_WORLD);</div>
<div class="line"><a name="l01534"></a><span class="lineno"> 1534</span>&#160;    </div>
<div class="line"><a name="l01535"></a><span class="lineno"> 1535</span>&#160;    <a class="code" href="structComplex.html">Complex</a> globalExpec;</div>
<div class="line"><a name="l01536"></a><span class="lineno"> 1536</span>&#160;    globalExpec.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a> = globalReal;</div>
<div class="line"><a name="l01537"></a><span class="lineno"> 1537</span>&#160;    globalExpec.<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a> = globalImag;</div>
<div class="line"><a name="l01538"></a><span class="lineno"> 1538</span>&#160;    <span class="keywordflow">return</span> globalExpec;</div>
<div class="line"><a name="l01539"></a><span class="lineno"> 1539</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00106">Complex::imag</a>, <a class="el" href="QuEST_8h_source.html#l00219">Qureg::numChunks</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST_8h_source.html#l00105">Complex::real</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l03738">statevec_calcExpecDiagonalOpLocal()</a>.</p>

</div>
</div>
<a id="a7ebd3198a198f4cd20840f64fd8b84d0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a7ebd3198a198f4cd20840f64fd8b84d0">&#9670;&nbsp;</a></span>statevec_calcInnerProduct()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="structComplex.html">Complex</a> statevec_calcInnerProduct </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>bra</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>ket</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00035">35</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;                                                        {</div>
<div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;    </div>
<div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;    <a class="code" href="structComplex.html">Complex</a> localInnerProd = <a class="code" href="QuEST__cpu_8c.html#a6fbb3b693f25dde1e9e3dc87dc1984f7">statevec_calcInnerProductLocal</a>(bra, ket);</div>
<div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;    <span class="keywordflow">if</span> (bra.<a class="code" href="structQureg.html#aa3deb7163aab90a61e755a1f200f5413">numChunks</a> == 1)</div>
<div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;        <span class="keywordflow">return</span> localInnerProd;</div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;    </div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> localReal = localInnerProd.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a>;</div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> localImag = localInnerProd.<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a>;</div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> globalReal, globalImag;</div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;    MPI_Allreduce(&amp;localReal, &amp;globalReal, 1, MPI_QuEST_REAL, MPI_SUM, MPI_COMM_WORLD);</div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;    MPI_Allreduce(&amp;localImag, &amp;globalImag, 1, MPI_QuEST_REAL, MPI_SUM, MPI_COMM_WORLD);</div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;    </div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;    <a class="code" href="structComplex.html">Complex</a> globalInnerProd;</div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;    globalInnerProd.<a class="code" href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">real</a> = globalReal;</div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;    globalInnerProd.<a class="code" href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">imag</a> = globalImag;</div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;    <span class="keywordflow">return</span> globalInnerProd;</div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00106">Complex::imag</a>, <a class="el" href="QuEST_8h_source.html#l00219">Qureg::numChunks</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST_8h_source.html#l00105">Complex::real</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l01071">statevec_calcInnerProductLocal()</a>.</p>

</div>
</div>
<a id="a63cb88a5f4eb12fef087435b8db3f8eb"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a63cb88a5f4eb12fef087435b8db3f8eb">&#9670;&nbsp;</a></span>statevec_calcProbOfOutcome()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> statevec_calcProbOfOutcome </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>measureQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>outcome</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01260">1260</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01261"></a><span class="lineno"> 1261</span>&#160;{</div>
<div class="line"><a name="l01262"></a><span class="lineno"> 1262</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> stateProb=0, totalStateProb=0;</div>
<div class="line"><a name="l01263"></a><span class="lineno"> 1263</span>&#160;    <span class="keywordtype">int</span> skipValuesWithinRank = <a class="code" href="QuEST__cpu__distributed_8c.html#a4d043bb0cee54a5f94faf3ffc34a6790">halfMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, measureQubit);</div>
<div class="line"><a name="l01264"></a><span class="lineno"> 1264</span>&#160;    <span class="keywordflow">if</span> (skipValuesWithinRank) {</div>
<div class="line"><a name="l01265"></a><span class="lineno"> 1265</span>&#160;        stateProb = <a class="code" href="QuEST__cpu_8c.html#a8535bc15c2ff249ddddb3fde6eff1490">statevec_findProbabilityOfZeroLocal</a>(qureg, measureQubit);</div>
<div class="line"><a name="l01266"></a><span class="lineno"> 1266</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l01267"></a><span class="lineno"> 1267</span>&#160;        <span class="keywordflow">if</span> (!<a class="code" href="QuEST__cpu__distributed_8c.html#af0ea25f00987af4c53f17c9cca62ab41">isChunkToSkipInFindPZero</a>(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, measureQubit)){</div>
<div class="line"><a name="l01268"></a><span class="lineno"> 1268</span>&#160;            stateProb = <a class="code" href="QuEST__cpu_8c.html#a430d98e35f1eae7f0815ac539057cf67">statevec_findProbabilityOfZeroDistributed</a>(qureg);</div>
<div class="line"><a name="l01269"></a><span class="lineno"> 1269</span>&#160;        } <span class="keywordflow">else</span> stateProb = 0;</div>
<div class="line"><a name="l01270"></a><span class="lineno"> 1270</span>&#160;    }</div>
<div class="line"><a name="l01271"></a><span class="lineno"> 1271</span>&#160;    MPI_Allreduce(&amp;stateProb, &amp;totalStateProb, 1, MPI_QuEST_REAL, MPI_SUM, MPI_COMM_WORLD);</div>
<div class="line"><a name="l01272"></a><span class="lineno"> 1272</span>&#160;    <span class="keywordflow">if</span> (outcome==1) totalStateProb = 1.0 - totalStateProb;</div>
<div class="line"><a name="l01273"></a><span class="lineno"> 1273</span>&#160;    <span class="keywordflow">return</span> totalStateProb;</div>
<div class="line"><a name="l01274"></a><span class="lineno"> 1274</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00356">halfMatrixBlockFitsInChunk()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01251">isChunkToSkipInFindPZero()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, <a class="el" href="QuEST__cpu_8c_source.html#l03262">statevec_findProbabilityOfZeroDistributed()</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l03206">statevec_findProbabilityOfZeroLocal()</a>.</p>

</div>
</div>
<a id="ad65ad1b5ea6f30b0c6b4ffda96e1a8e6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad65ad1b5ea6f30b0c6b4ffda96e1a8e6">&#9670;&nbsp;</a></span>statevec_calcTotalProb()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> statevec_calcTotalProb </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00088">88</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;                                         {</div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;    <span class="comment">// Implemented using Kahan summation for greater accuracy at a slight floating</span></div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;    <span class="comment">//   point operation overhead. For more details see https://en.wikipedia.org/wiki/Kahan_summation_algorithm</span></div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> pTotal=0; </div>
<div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> y, t, c;</div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> allRankTotals=0;</div>
<div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> index;</div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> numAmpsPerRank = qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;    c = 0.0;</div>
<div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;    <span class="keywordflow">for</span> (index=0; index&lt;numAmpsPerRank; index++){ </div>
<div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;        <span class="comment">// Perform pTotal+=qureg.stateVec.real[index]*qureg.stateVec.real[index]; by Kahan</span></div>
<div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;        y = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real[index]*qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real[index] - c;</div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;        t = pTotal + y;</div>
<div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;        <span class="comment">// Don&#39;t change the bracketing on the following line</span></div>
<div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;        c = ( t - pTotal ) - y;</div>
<div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;        pTotal = t;</div>
<div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;        <span class="comment">// Perform pTotal+=qureg.stateVec.imag[index]*qureg.stateVec.imag[index]; by Kahan</span></div>
<div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;        y = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag[index]*qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag[index] - c;</div>
<div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;        t = pTotal + y;</div>
<div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;        <span class="comment">// Don&#39;t change the bracketing on the following line</span></div>
<div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;        c = ( t - pTotal ) - y;</div>
<div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;        pTotal = t;</div>
<div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;    } </div>
<div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;    <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#aa3deb7163aab90a61e755a1f200f5413">numChunks</a>&gt;1)</div>
<div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;                MPI_Allreduce(&amp;pTotal, &amp;allRankTotals, 1, MPI_QuEST_REAL, MPI_SUM, MPI_COMM_WORLD);</div>
<div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160;    <span class="keywordflow">else</span> </div>
<div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;                allRankTotals=pTotal;</div>
<div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160; </div>
<div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;    <span class="keywordflow">return</span> allRankTotals;</div>
<div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00219">Qureg::numChunks</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>

</div>
</div>
<a id="ab07dc84ee1f2034482f1c186576434be"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab07dc84ee1f2034482f1c186576434be">&#9670;&nbsp;</a></span>statevec_collapseToKnownProbOutcome()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_collapseToKnownProbOutcome </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>measureQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>outcome</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>&#160;</td>
          <td class="paramname"><em>totalStateProb</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01298">1298</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01299"></a><span class="lineno"> 1299</span>&#160;{</div>
<div class="line"><a name="l01300"></a><span class="lineno"> 1300</span>&#160;    <span class="keywordtype">int</span> skipValuesWithinRank = <a class="code" href="QuEST__cpu__distributed_8c.html#a4d043bb0cee54a5f94faf3ffc34a6790">halfMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, measureQubit);</div>
<div class="line"><a name="l01301"></a><span class="lineno"> 1301</span>&#160;    <span class="keywordflow">if</span> (skipValuesWithinRank) {</div>
<div class="line"><a name="l01302"></a><span class="lineno"> 1302</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#ab02bce0ebbb8f624e8ced8b09b99cdef">statevec_collapseToKnownProbOutcomeLocal</a>(qureg, measureQubit, outcome, totalStateProb);</div>
<div class="line"><a name="l01303"></a><span class="lineno"> 1303</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l01304"></a><span class="lineno"> 1304</span>&#160;        <span class="keywordflow">if</span> (!<a class="code" href="QuEST__cpu__distributed_8c.html#af0ea25f00987af4c53f17c9cca62ab41">isChunkToSkipInFindPZero</a>(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, measureQubit)){</div>
<div class="line"><a name="l01305"></a><span class="lineno"> 1305</span>&#160;            <span class="comment">// chunk has amps for q=0</span></div>
<div class="line"><a name="l01306"></a><span class="lineno"> 1306</span>&#160;            <span class="keywordflow">if</span> (outcome==0) <a class="code" href="QuEST__cpu_8c.html#ad09bb76ad67581b03ab176832cca37cf">statevec_collapseToKnownProbOutcomeDistributedRenorm</a>(qureg, measureQubit, </div>
<div class="line"><a name="l01307"></a><span class="lineno"> 1307</span>&#160;                    totalStateProb);</div>
<div class="line"><a name="l01308"></a><span class="lineno"> 1308</span>&#160;            <span class="keywordflow">else</span> <a class="code" href="QuEST__cpu_8c.html#a7ea68e9132ed9db9c242353a33dba2f0">statevec_collapseToOutcomeDistributedSetZero</a>(qureg);</div>
<div class="line"><a name="l01309"></a><span class="lineno"> 1309</span>&#160;        } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l01310"></a><span class="lineno"> 1310</span>&#160;            <span class="comment">// chunk has amps for q=1</span></div>
<div class="line"><a name="l01311"></a><span class="lineno"> 1311</span>&#160;            <span class="keywordflow">if</span> (outcome==1) <a class="code" href="QuEST__cpu_8c.html#ad09bb76ad67581b03ab176832cca37cf">statevec_collapseToKnownProbOutcomeDistributedRenorm</a>(qureg, measureQubit, </div>
<div class="line"><a name="l01312"></a><span class="lineno"> 1312</span>&#160;                    totalStateProb);</div>
<div class="line"><a name="l01313"></a><span class="lineno"> 1313</span>&#160;            <span class="keywordflow">else</span> <a class="code" href="QuEST__cpu_8c.html#a7ea68e9132ed9db9c242353a33dba2f0">statevec_collapseToOutcomeDistributedSetZero</a>(qureg);</div>
<div class="line"><a name="l01314"></a><span class="lineno"> 1314</span>&#160;        }</div>
<div class="line"><a name="l01315"></a><span class="lineno"> 1315</span>&#160;    }</div>
<div class="line"><a name="l01316"></a><span class="lineno"> 1316</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00356">halfMatrixBlockFitsInChunk()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01251">isChunkToSkipInFindPZero()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST__cpu_8c_source.html#l03462">statevec_collapseToKnownProbOutcomeDistributedRenorm()</a>, <a class="el" href="QuEST__cpu_8c_source.html#l03380">statevec_collapseToKnownProbOutcomeLocal()</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l03501">statevec_collapseToOutcomeDistributedSetZero()</a>.</p>

</div>
</div>
<a id="aec63559e8b9ab0e17efe18d64d2ceca6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aec63559e8b9ab0e17efe18d64d2ceca6">&#9670;&nbsp;</a></span>statevec_compactUnitary()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_compactUnitary </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplex.html">Complex</a>&#160;</td>
          <td class="paramname"><em>alpha</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplex.html">Complex</a>&#160;</td>
          <td class="paramname"><em>beta</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00844">844</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00845"></a><span class="lineno">  845</span>&#160;{</div>
<div class="line"><a name="l00846"></a><span class="lineno">  846</span>&#160;    <span class="comment">// flag to require memory exchange. 1: an entire block fits on one rank, 0: at most half a block fits on one rank</span></div>
<div class="line"><a name="l00847"></a><span class="lineno">  847</span>&#160;    <span class="keywordtype">int</span> useLocalDataOnly = <a class="code" href="QuEST__cpu__distributed_8c.html#a4d043bb0cee54a5f94faf3ffc34a6790">halfMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l00848"></a><span class="lineno">  848</span>&#160;    <a class="code" href="structComplex.html">Complex</a> rot1, rot2;</div>
<div class="line"><a name="l00849"></a><span class="lineno">  849</span>&#160; </div>
<div class="line"><a name="l00850"></a><span class="lineno">  850</span>&#160;    <span class="comment">// rank&#39;s chunk is in upper half of block </span></div>
<div class="line"><a name="l00851"></a><span class="lineno">  851</span>&#160;    <span class="keywordtype">int</span> rankIsUpper;</div>
<div class="line"><a name="l00852"></a><span class="lineno">  852</span>&#160;    <span class="keywordtype">int</span> pairRank; <span class="comment">// rank of corresponding chunk</span></div>
<div class="line"><a name="l00853"></a><span class="lineno">  853</span>&#160; </div>
<div class="line"><a name="l00854"></a><span class="lineno">  854</span>&#160;    <span class="keywordflow">if</span> (useLocalDataOnly){</div>
<div class="line"><a name="l00855"></a><span class="lineno">  855</span>&#160;        <span class="comment">// all values required to update state vector lie in this rank</span></div>
<div class="line"><a name="l00856"></a><span class="lineno">  856</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#a5ddfdb22e4704b680d67d08d9e80835b">statevec_compactUnitaryLocal</a>(qureg, targetQubit, alpha, beta);</div>
<div class="line"><a name="l00857"></a><span class="lineno">  857</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00858"></a><span class="lineno">  858</span>&#160;        <span class="comment">// need to get corresponding chunk of state vector from other rank</span></div>
<div class="line"><a name="l00859"></a><span class="lineno">  859</span>&#160;        rankIsUpper = <a class="code" href="QuEST__cpu__distributed_8c.html#a0552889d6f57d9e0ed8b209bf426482d">chunkIsUpper</a>(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l00860"></a><span class="lineno">  860</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#adb4b0373425b282abed27742d0ce0872">getRotAngle</a>(rankIsUpper, &amp;rot1, &amp;rot2, alpha, beta);</div>
<div class="line"><a name="l00861"></a><span class="lineno">  861</span>&#160;        pairRank = <a class="code" href="QuEST__cpu__distributed_8c.html#a7dba097f23f5d48dfdc9f3250444e2e4">getChunkPairId</a>(rankIsUpper, qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l00862"></a><span class="lineno">  862</span>&#160;        <span class="comment">// get corresponding values from my pair</span></div>
<div class="line"><a name="l00863"></a><span class="lineno">  863</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#ae01c3eb75fd32de1a7e1dbc7a33a21e3">exchangeStateVectors</a>(qureg, pairRank);</div>
<div class="line"><a name="l00864"></a><span class="lineno">  864</span>&#160; </div>
<div class="line"><a name="l00865"></a><span class="lineno">  865</span>&#160;        <span class="comment">// this rank&#39;s values are either in the upper of lower half of the block. </span></div>
<div class="line"><a name="l00866"></a><span class="lineno">  866</span>&#160;        <span class="comment">// send values to compactUnitaryDistributed in the correct order</span></div>
<div class="line"><a name="l00867"></a><span class="lineno">  867</span>&#160;        <span class="keywordflow">if</span> (rankIsUpper){</div>
<div class="line"><a name="l00868"></a><span class="lineno">  868</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#a0a7a35628b1c1eb47336deb9afda5b68">statevec_compactUnitaryDistributed</a>(qureg,rot1,rot2,</div>
<div class="line"><a name="l00869"></a><span class="lineno">  869</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>, <span class="comment">//upper</span></div>
<div class="line"><a name="l00870"></a><span class="lineno">  870</span>&#160;                    qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">//lower</span></div>
<div class="line"><a name="l00871"></a><span class="lineno">  871</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>); <span class="comment">//output</span></div>
<div class="line"><a name="l00872"></a><span class="lineno">  872</span>&#160;        } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00873"></a><span class="lineno">  873</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#a0a7a35628b1c1eb47336deb9afda5b68">statevec_compactUnitaryDistributed</a>(qureg,rot1,rot2,</div>
<div class="line"><a name="l00874"></a><span class="lineno">  874</span>&#160;                    qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">//upper</span></div>
<div class="line"><a name="l00875"></a><span class="lineno">  875</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>, <span class="comment">//lower</span></div>
<div class="line"><a name="l00876"></a><span class="lineno">  876</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>); <span class="comment">//output</span></div>
<div class="line"><a name="l00877"></a><span class="lineno">  877</span>&#160;        }</div>
<div class="line"><a name="l00878"></a><span class="lineno">  878</span>&#160;    }</div>
<div class="line"><a name="l00879"></a><span class="lineno">  879</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00227">chunkIsUpper()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00479">exchangeStateVectors()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00303">getChunkPairId()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00258">getRotAngle()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00356">halfMatrixBlockFitsInChunk()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00224">Qureg::pairStateVec</a>, <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>, <a class="el" href="QuEST__cpu_8c_source.html#l02001">statevec_compactUnitaryDistributed()</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l01688">statevec_compactUnitaryLocal()</a>.</p>

</div>
</div>
<a id="a1275d604674224d87a173fb5bac78835"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a1275d604674224d87a173fb5bac78835">&#9670;&nbsp;</a></span>statevec_controlledCompactUnitary()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_controlledCompactUnitary </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>controlQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplex.html">Complex</a>&#160;</td>
          <td class="paramname"><em>alpha</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplex.html">Complex</a>&#160;</td>
          <td class="paramname"><em>beta</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00920">920</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00921"></a><span class="lineno">  921</span>&#160;{</div>
<div class="line"><a name="l00922"></a><span class="lineno">  922</span>&#160;    <span class="comment">// flag to require memory exchange. 1: an entire block fits on one rank, 0: at most half a block fits on one rank</span></div>
<div class="line"><a name="l00923"></a><span class="lineno">  923</span>&#160;    <span class="keywordtype">int</span> useLocalDataOnly = <a class="code" href="QuEST__cpu__distributed_8c.html#a4d043bb0cee54a5f94faf3ffc34a6790">halfMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l00924"></a><span class="lineno">  924</span>&#160;    <a class="code" href="structComplex.html">Complex</a> rot1, rot2;</div>
<div class="line"><a name="l00925"></a><span class="lineno">  925</span>&#160; </div>
<div class="line"><a name="l00926"></a><span class="lineno">  926</span>&#160;    <span class="comment">// rank&#39;s chunk is in upper half of block </span></div>
<div class="line"><a name="l00927"></a><span class="lineno">  927</span>&#160;    <span class="keywordtype">int</span> rankIsUpper;</div>
<div class="line"><a name="l00928"></a><span class="lineno">  928</span>&#160;    <span class="keywordtype">int</span> pairRank; <span class="comment">// rank of corresponding chunk</span></div>
<div class="line"><a name="l00929"></a><span class="lineno">  929</span>&#160; </div>
<div class="line"><a name="l00930"></a><span class="lineno">  930</span>&#160;    <span class="keywordflow">if</span> (useLocalDataOnly){</div>
<div class="line"><a name="l00931"></a><span class="lineno">  931</span>&#160;        <span class="comment">// all values required to update state vector lie in this rank</span></div>
<div class="line"><a name="l00932"></a><span class="lineno">  932</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#a215e2d6f88dbecc0b408b3573b5e144f">statevec_controlledCompactUnitaryLocal</a>(qureg, controlQubit, targetQubit, alpha, beta);</div>
<div class="line"><a name="l00933"></a><span class="lineno">  933</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00934"></a><span class="lineno">  934</span>&#160;        <span class="comment">// need to get corresponding chunk of state vector from other rank</span></div>
<div class="line"><a name="l00935"></a><span class="lineno">  935</span>&#160;        rankIsUpper = <a class="code" href="QuEST__cpu__distributed_8c.html#a0552889d6f57d9e0ed8b209bf426482d">chunkIsUpper</a>(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l00936"></a><span class="lineno">  936</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#adb4b0373425b282abed27742d0ce0872">getRotAngle</a>(rankIsUpper, &amp;rot1, &amp;rot2, alpha, beta);</div>
<div class="line"><a name="l00937"></a><span class="lineno">  937</span>&#160;        pairRank = <a class="code" href="QuEST__cpu__distributed_8c.html#a7dba097f23f5d48dfdc9f3250444e2e4">getChunkPairId</a>(rankIsUpper, qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l00938"></a><span class="lineno">  938</span>&#160;        <span class="comment">//printf(&quot;%d rank has pair rank: %d\n&quot;, qureg.rank, pairRank);</span></div>
<div class="line"><a name="l00939"></a><span class="lineno">  939</span>&#160;        <span class="comment">// get corresponding values from my pair</span></div>
<div class="line"><a name="l00940"></a><span class="lineno">  940</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#ae01c3eb75fd32de1a7e1dbc7a33a21e3">exchangeStateVectors</a>(qureg, pairRank);</div>
<div class="line"><a name="l00941"></a><span class="lineno">  941</span>&#160; </div>
<div class="line"><a name="l00942"></a><span class="lineno">  942</span>&#160;        <span class="comment">// this rank&#39;s values are either in the upper of lower half of the block. send values to controlledCompactUnitaryDistributed</span></div>
<div class="line"><a name="l00943"></a><span class="lineno">  943</span>&#160;        <span class="comment">// in the correct order</span></div>
<div class="line"><a name="l00944"></a><span class="lineno">  944</span>&#160;        <span class="keywordflow">if</span> (rankIsUpper){</div>
<div class="line"><a name="l00945"></a><span class="lineno">  945</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#a071baf8b6951d2a7d6529394b6f39364">statevec_controlledCompactUnitaryDistributed</a>(qureg,controlQubit,rot1,rot2,</div>
<div class="line"><a name="l00946"></a><span class="lineno">  946</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>, <span class="comment">//upper</span></div>
<div class="line"><a name="l00947"></a><span class="lineno">  947</span>&#160;                    qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">//lower</span></div>
<div class="line"><a name="l00948"></a><span class="lineno">  948</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>); <span class="comment">//output</span></div>
<div class="line"><a name="l00949"></a><span class="lineno">  949</span>&#160;        } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00950"></a><span class="lineno">  950</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#a071baf8b6951d2a7d6529394b6f39364">statevec_controlledCompactUnitaryDistributed</a>(qureg,controlQubit,rot1,rot2,</div>
<div class="line"><a name="l00951"></a><span class="lineno">  951</span>&#160;                    qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">//upper</span></div>
<div class="line"><a name="l00952"></a><span class="lineno">  952</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>, <span class="comment">//lower</span></div>
<div class="line"><a name="l00953"></a><span class="lineno">  953</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>); <span class="comment">//output</span></div>
<div class="line"><a name="l00954"></a><span class="lineno">  954</span>&#160;        }</div>
<div class="line"><a name="l00955"></a><span class="lineno">  955</span>&#160;    }</div>
<div class="line"><a name="l00956"></a><span class="lineno">  956</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00227">chunkIsUpper()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00479">exchangeStateVectors()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00303">getChunkPairId()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00258">getRotAngle()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00356">halfMatrixBlockFitsInChunk()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00224">Qureg::pairStateVec</a>, <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>, <a class="el" href="QuEST__cpu_8c_source.html#l02319">statevec_controlledCompactUnitaryDistributed()</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l02101">statevec_controlledCompactUnitaryLocal()</a>.</p>

</div>
</div>
<a id="abb2eab4af99adcc59be24f4c91c6f6ad"></a>
<h2 class="memtitle"><span class="permalink"><a href="#abb2eab4af99adcc59be24f4c91c6f6ad">&#9670;&nbsp;</a></span>statevec_controlledNot()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_controlledNot </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>controlQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01061">1061</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01062"></a><span class="lineno"> 1062</span>&#160;{</div>
<div class="line"><a name="l01063"></a><span class="lineno"> 1063</span>&#160;    <span class="comment">// flag to require memory exchange. 1: an entire block fits on one rank, 0: at most half a block fits on one rank</span></div>
<div class="line"><a name="l01064"></a><span class="lineno"> 1064</span>&#160;    <span class="keywordtype">int</span> useLocalDataOnly = <a class="code" href="QuEST__cpu__distributed_8c.html#a4d043bb0cee54a5f94faf3ffc34a6790">halfMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01065"></a><span class="lineno"> 1065</span>&#160;    <span class="keywordtype">int</span> rankIsUpper;    <span class="comment">// rank&#39;s chunk is in upper half of block </span></div>
<div class="line"><a name="l01066"></a><span class="lineno"> 1066</span>&#160;    <span class="keywordtype">int</span> pairRank;               <span class="comment">// rank of corresponding chunk</span></div>
<div class="line"><a name="l01067"></a><span class="lineno"> 1067</span>&#160; </div>
<div class="line"><a name="l01068"></a><span class="lineno"> 1068</span>&#160;    <span class="keywordflow">if</span> (useLocalDataOnly){</div>
<div class="line"><a name="l01069"></a><span class="lineno"> 1069</span>&#160;        <span class="comment">// all values required to update state vector lie in this rank</span></div>
<div class="line"><a name="l01070"></a><span class="lineno"> 1070</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#ace1482ef82b83e7f926634a67b322fc4">statevec_controlledNotLocal</a>(qureg, controlQubit, targetQubit);</div>
<div class="line"><a name="l01071"></a><span class="lineno"> 1071</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l01072"></a><span class="lineno"> 1072</span>&#160;        <span class="comment">// need to get corresponding chunk of state vector from other rank</span></div>
<div class="line"><a name="l01073"></a><span class="lineno"> 1073</span>&#160;        rankIsUpper = <a class="code" href="QuEST__cpu__distributed_8c.html#a0552889d6f57d9e0ed8b209bf426482d">chunkIsUpper</a>(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01074"></a><span class="lineno"> 1074</span>&#160;        pairRank = <a class="code" href="QuEST__cpu__distributed_8c.html#a7dba097f23f5d48dfdc9f3250444e2e4">getChunkPairId</a>(rankIsUpper, qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01075"></a><span class="lineno"> 1075</span>&#160;        <span class="comment">// get corresponding values from my pair</span></div>
<div class="line"><a name="l01076"></a><span class="lineno"> 1076</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#ae01c3eb75fd32de1a7e1dbc7a33a21e3">exchangeStateVectors</a>(qureg, pairRank);</div>
<div class="line"><a name="l01077"></a><span class="lineno"> 1077</span>&#160;        <span class="comment">// this rank&#39;s values are either in the upper of lower half of the block</span></div>
<div class="line"><a name="l01078"></a><span class="lineno"> 1078</span>&#160;        <span class="keywordflow">if</span> (rankIsUpper){</div>
<div class="line"><a name="l01079"></a><span class="lineno"> 1079</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#a393da4c4bc582a757ca8406d8501aca0">statevec_controlledNotDistributed</a>(qureg,controlQubit,</div>
<div class="line"><a name="l01080"></a><span class="lineno"> 1080</span>&#160;                    qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">//in</span></div>
<div class="line"><a name="l01081"></a><span class="lineno"> 1081</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>); <span class="comment">//out</span></div>
<div class="line"><a name="l01082"></a><span class="lineno"> 1082</span>&#160;        } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l01083"></a><span class="lineno"> 1083</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#a393da4c4bc582a757ca8406d8501aca0">statevec_controlledNotDistributed</a>(qureg,controlQubit,</div>
<div class="line"><a name="l01084"></a><span class="lineno"> 1084</span>&#160;                    qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">//in</span></div>
<div class="line"><a name="l01085"></a><span class="lineno"> 1085</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>); <span class="comment">//out</span></div>
<div class="line"><a name="l01086"></a><span class="lineno"> 1086</span>&#160;        }</div>
<div class="line"><a name="l01087"></a><span class="lineno"> 1087</span>&#160;    }</div>
<div class="line"><a name="l01088"></a><span class="lineno"> 1088</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00227">chunkIsUpper()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00479">exchangeStateVectors()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00303">getChunkPairId()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00356">halfMatrixBlockFitsInChunk()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00224">Qureg::pairStateVec</a>, <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>, <a class="el" href="QuEST__cpu_8c_source.html#l02646">statevec_controlledNotDistributed()</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l02584">statevec_controlledNotLocal()</a>.</p>

</div>
</div>
<a id="a4e19ef93d01d7acea32ca646d623aedd"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a4e19ef93d01d7acea32ca646d623aedd">&#9670;&nbsp;</a></span>statevec_controlledPauliY()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_controlledPauliY </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>controlQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01140">1140</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01141"></a><span class="lineno"> 1141</span>&#160;{</div>
<div class="line"><a name="l01142"></a><span class="lineno"> 1142</span>&#160;        <span class="keywordtype">int</span> conjFac = 1;</div>
<div class="line"><a name="l01143"></a><span class="lineno"> 1143</span>&#160; </div>
<div class="line"><a name="l01144"></a><span class="lineno"> 1144</span>&#160;    <span class="comment">// flag to require memory exchange. 1: an entire block fits on one rank, 0: at most half a block fits on one rank</span></div>
<div class="line"><a name="l01145"></a><span class="lineno"> 1145</span>&#160;    <span class="keywordtype">int</span> useLocalDataOnly = <a class="code" href="QuEST__cpu__distributed_8c.html#a4d043bb0cee54a5f94faf3ffc34a6790">halfMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01146"></a><span class="lineno"> 1146</span>&#160;    <span class="keywordtype">int</span> rankIsUpper;    <span class="comment">// rank&#39;s chunk is in upper half of block </span></div>
<div class="line"><a name="l01147"></a><span class="lineno"> 1147</span>&#160;    <span class="keywordtype">int</span> pairRank;               <span class="comment">// rank of corresponding chunk</span></div>
<div class="line"><a name="l01148"></a><span class="lineno"> 1148</span>&#160; </div>
<div class="line"><a name="l01149"></a><span class="lineno"> 1149</span>&#160;    <span class="keywordflow">if</span> (useLocalDataOnly){</div>
<div class="line"><a name="l01150"></a><span class="lineno"> 1150</span>&#160;        <span class="comment">// all values required to update state vector lie in this rank</span></div>
<div class="line"><a name="l01151"></a><span class="lineno"> 1151</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#a06fb16aa4af7c54d36052a14d3ad58a7">statevec_controlledPauliYLocal</a>(qureg, controlQubit, targetQubit, conjFac);</div>
<div class="line"><a name="l01152"></a><span class="lineno"> 1152</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l01153"></a><span class="lineno"> 1153</span>&#160;        <span class="comment">// need to get corresponding chunk of state vector from other rank</span></div>
<div class="line"><a name="l01154"></a><span class="lineno"> 1154</span>&#160;        rankIsUpper = <a class="code" href="QuEST__cpu__distributed_8c.html#a0552889d6f57d9e0ed8b209bf426482d">chunkIsUpper</a>(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01155"></a><span class="lineno"> 1155</span>&#160;        pairRank = <a class="code" href="QuEST__cpu__distributed_8c.html#a7dba097f23f5d48dfdc9f3250444e2e4">getChunkPairId</a>(rankIsUpper, qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01156"></a><span class="lineno"> 1156</span>&#160;        <span class="comment">// get corresponding values from my pair</span></div>
<div class="line"><a name="l01157"></a><span class="lineno"> 1157</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#ae01c3eb75fd32de1a7e1dbc7a33a21e3">exchangeStateVectors</a>(qureg, pairRank);</div>
<div class="line"><a name="l01158"></a><span class="lineno"> 1158</span>&#160;        <span class="comment">// this rank&#39;s values are either in the upper of lower half of the block</span></div>
<div class="line"><a name="l01159"></a><span class="lineno"> 1159</span>&#160;        <span class="keywordflow">if</span> (rankIsUpper){</div>
<div class="line"><a name="l01160"></a><span class="lineno"> 1160</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#a790add229738945812ae2048c03d58ec">statevec_controlledPauliYDistributed</a>(qureg,controlQubit,</div>
<div class="line"><a name="l01161"></a><span class="lineno"> 1161</span>&#160;                    qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">//in</span></div>
<div class="line"><a name="l01162"></a><span class="lineno"> 1162</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>,</div>
<div class="line"><a name="l01163"></a><span class="lineno"> 1163</span>&#160;                                        conjFac); <span class="comment">//out</span></div>
<div class="line"><a name="l01164"></a><span class="lineno"> 1164</span>&#160;        } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l01165"></a><span class="lineno"> 1165</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#a790add229738945812ae2048c03d58ec">statevec_controlledPauliYDistributed</a>(qureg,controlQubit,</div>
<div class="line"><a name="l01166"></a><span class="lineno"> 1166</span>&#160;                    qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">//in</span></div>
<div class="line"><a name="l01167"></a><span class="lineno"> 1167</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>,</div>
<div class="line"><a name="l01168"></a><span class="lineno"> 1168</span>&#160;                                        -conjFac); <span class="comment">//out</span></div>
<div class="line"><a name="l01169"></a><span class="lineno"> 1169</span>&#160;        }</div>
<div class="line"><a name="l01170"></a><span class="lineno"> 1170</span>&#160;    }</div>
<div class="line"><a name="l01171"></a><span class="lineno"> 1171</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00227">chunkIsUpper()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00479">exchangeStateVectors()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00303">getChunkPairId()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00356">halfMatrixBlockFitsInChunk()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00224">Qureg::pairStateVec</a>, <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>, <a class="el" href="QuEST__cpu_8c_source.html#l02830">statevec_controlledPauliYDistributed()</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l02776">statevec_controlledPauliYLocal()</a>.</p>

</div>
</div>
<a id="a4a2fa262d3f0dba372797b9bd35d9fa5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a4a2fa262d3f0dba372797b9bd35d9fa5">&#9670;&nbsp;</a></span>statevec_controlledPauliYConj()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_controlledPauliYConj </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>controlQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01173">1173</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01174"></a><span class="lineno"> 1174</span>&#160;{</div>
<div class="line"><a name="l01175"></a><span class="lineno"> 1175</span>&#160;        <span class="keywordtype">int</span> conjFac = -1;</div>
<div class="line"><a name="l01176"></a><span class="lineno"> 1176</span>&#160; </div>
<div class="line"><a name="l01177"></a><span class="lineno"> 1177</span>&#160;    <span class="comment">// flag to require memory exchange. 1: an entire block fits on one rank, 0: at most half a block fits on one rank</span></div>
<div class="line"><a name="l01178"></a><span class="lineno"> 1178</span>&#160;    <span class="keywordtype">int</span> useLocalDataOnly = <a class="code" href="QuEST__cpu__distributed_8c.html#a4d043bb0cee54a5f94faf3ffc34a6790">halfMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01179"></a><span class="lineno"> 1179</span>&#160;    <span class="keywordtype">int</span> rankIsUpper;    <span class="comment">// rank&#39;s chunk is in upper half of block </span></div>
<div class="line"><a name="l01180"></a><span class="lineno"> 1180</span>&#160;    <span class="keywordtype">int</span> pairRank;               <span class="comment">// rank of corresponding chunk</span></div>
<div class="line"><a name="l01181"></a><span class="lineno"> 1181</span>&#160; </div>
<div class="line"><a name="l01182"></a><span class="lineno"> 1182</span>&#160;    <span class="keywordflow">if</span> (useLocalDataOnly){</div>
<div class="line"><a name="l01183"></a><span class="lineno"> 1183</span>&#160;        <span class="comment">// all values required to update state vector lie in this rank</span></div>
<div class="line"><a name="l01184"></a><span class="lineno"> 1184</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#a06fb16aa4af7c54d36052a14d3ad58a7">statevec_controlledPauliYLocal</a>(qureg, controlQubit, targetQubit, conjFac);</div>
<div class="line"><a name="l01185"></a><span class="lineno"> 1185</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l01186"></a><span class="lineno"> 1186</span>&#160;        <span class="comment">// need to get corresponding chunk of state vector from other rank</span></div>
<div class="line"><a name="l01187"></a><span class="lineno"> 1187</span>&#160;        rankIsUpper = <a class="code" href="QuEST__cpu__distributed_8c.html#a0552889d6f57d9e0ed8b209bf426482d">chunkIsUpper</a>(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01188"></a><span class="lineno"> 1188</span>&#160;        pairRank = <a class="code" href="QuEST__cpu__distributed_8c.html#a7dba097f23f5d48dfdc9f3250444e2e4">getChunkPairId</a>(rankIsUpper, qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01189"></a><span class="lineno"> 1189</span>&#160;        <span class="comment">// get corresponding values from my pair</span></div>
<div class="line"><a name="l01190"></a><span class="lineno"> 1190</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#ae01c3eb75fd32de1a7e1dbc7a33a21e3">exchangeStateVectors</a>(qureg, pairRank);</div>
<div class="line"><a name="l01191"></a><span class="lineno"> 1191</span>&#160;        <span class="comment">// this rank&#39;s values are either in the upper of lower half of the block</span></div>
<div class="line"><a name="l01192"></a><span class="lineno"> 1192</span>&#160;        <span class="keywordflow">if</span> (rankIsUpper){</div>
<div class="line"><a name="l01193"></a><span class="lineno"> 1193</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#a790add229738945812ae2048c03d58ec">statevec_controlledPauliYDistributed</a>(qureg,controlQubit,</div>
<div class="line"><a name="l01194"></a><span class="lineno"> 1194</span>&#160;                    qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">//in</span></div>
<div class="line"><a name="l01195"></a><span class="lineno"> 1195</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>,</div>
<div class="line"><a name="l01196"></a><span class="lineno"> 1196</span>&#160;                                        conjFac); <span class="comment">//out</span></div>
<div class="line"><a name="l01197"></a><span class="lineno"> 1197</span>&#160;        } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l01198"></a><span class="lineno"> 1198</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#a790add229738945812ae2048c03d58ec">statevec_controlledPauliYDistributed</a>(qureg,controlQubit,</div>
<div class="line"><a name="l01199"></a><span class="lineno"> 1199</span>&#160;                    qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">//in</span></div>
<div class="line"><a name="l01200"></a><span class="lineno"> 1200</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>,</div>
<div class="line"><a name="l01201"></a><span class="lineno"> 1201</span>&#160;                                        -conjFac); <span class="comment">//out</span></div>
<div class="line"><a name="l01202"></a><span class="lineno"> 1202</span>&#160;        }</div>
<div class="line"><a name="l01203"></a><span class="lineno"> 1203</span>&#160;    }</div>
<div class="line"><a name="l01204"></a><span class="lineno"> 1204</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00227">chunkIsUpper()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00479">exchangeStateVectors()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00303">getChunkPairId()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00356">halfMatrixBlockFitsInChunk()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00224">Qureg::pairStateVec</a>, <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>, <a class="el" href="QuEST__cpu_8c_source.html#l02830">statevec_controlledPauliYDistributed()</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l02776">statevec_controlledPauliYLocal()</a>.</p>

</div>
</div>
<a id="add9ca9956cdd81ed5d0b0f66168c04a3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#add9ca9956cdd81ed5d0b0f66168c04a3">&#9670;&nbsp;</a></span>statevec_controlledUnitary()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_controlledUnitary </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>controlQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplexMatrix2.html">ComplexMatrix2</a>&#160;</td>
          <td class="paramname"><em>u</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00958">958</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00960"></a><span class="lineno">  960</span>&#160;{</div>
<div class="line"><a name="l00961"></a><span class="lineno">  961</span>&#160;    <span class="comment">// flag to require memory exchange. 1: an entire block fits on one rank, 0: at most half a block fits on one rank</span></div>
<div class="line"><a name="l00962"></a><span class="lineno">  962</span>&#160;    <span class="keywordtype">int</span> useLocalDataOnly = <a class="code" href="QuEST__cpu__distributed_8c.html#a4d043bb0cee54a5f94faf3ffc34a6790">halfMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l00963"></a><span class="lineno">  963</span>&#160;    <a class="code" href="structComplex.html">Complex</a> rot1, rot2;</div>
<div class="line"><a name="l00964"></a><span class="lineno">  964</span>&#160; </div>
<div class="line"><a name="l00965"></a><span class="lineno">  965</span>&#160;    <span class="comment">// rank&#39;s chunk is in upper half of block </span></div>
<div class="line"><a name="l00966"></a><span class="lineno">  966</span>&#160;    <span class="keywordtype">int</span> rankIsUpper;</div>
<div class="line"><a name="l00967"></a><span class="lineno">  967</span>&#160;    <span class="keywordtype">int</span> pairRank; <span class="comment">// rank of corresponding chunk</span></div>
<div class="line"><a name="l00968"></a><span class="lineno">  968</span>&#160; </div>
<div class="line"><a name="l00969"></a><span class="lineno">  969</span>&#160;    <span class="keywordflow">if</span> (useLocalDataOnly){</div>
<div class="line"><a name="l00970"></a><span class="lineno">  970</span>&#160;        <span class="comment">// all values required to update state vector lie in this rank</span></div>
<div class="line"><a name="l00971"></a><span class="lineno">  971</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#a903beb4f5d8753a964ce2dc5f9096a24">statevec_controlledUnitaryLocal</a>(qureg, controlQubit, targetQubit, u);</div>
<div class="line"><a name="l00972"></a><span class="lineno">  972</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00973"></a><span class="lineno">  973</span>&#160;        <span class="comment">// need to get corresponding chunk of state vector from other rank</span></div>
<div class="line"><a name="l00974"></a><span class="lineno">  974</span>&#160;        rankIsUpper = <a class="code" href="QuEST__cpu__distributed_8c.html#a0552889d6f57d9e0ed8b209bf426482d">chunkIsUpper</a>(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l00975"></a><span class="lineno">  975</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#a5c9b2f129bdffaaba9857f6eddecbb17">getRotAngleFromUnitaryMatrix</a>(rankIsUpper, &amp;rot1, &amp;rot2, u);</div>
<div class="line"><a name="l00976"></a><span class="lineno">  976</span>&#160;        pairRank = <a class="code" href="QuEST__cpu__distributed_8c.html#a7dba097f23f5d48dfdc9f3250444e2e4">getChunkPairId</a>(rankIsUpper, qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l00977"></a><span class="lineno">  977</span>&#160;        <span class="comment">//printf(&quot;%d rank has pair rank: %d\n&quot;, qureg.rank, pairRank);</span></div>
<div class="line"><a name="l00978"></a><span class="lineno">  978</span>&#160;        <span class="comment">// get corresponding values from my pair</span></div>
<div class="line"><a name="l00979"></a><span class="lineno">  979</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#ae01c3eb75fd32de1a7e1dbc7a33a21e3">exchangeStateVectors</a>(qureg, pairRank);</div>
<div class="line"><a name="l00980"></a><span class="lineno">  980</span>&#160; </div>
<div class="line"><a name="l00981"></a><span class="lineno">  981</span>&#160;        <span class="comment">// this rank&#39;s values are either in the upper of lower half of the block. send values to controlledUnitaryDistributed</span></div>
<div class="line"><a name="l00982"></a><span class="lineno">  982</span>&#160;        <span class="comment">// in the correct order</span></div>
<div class="line"><a name="l00983"></a><span class="lineno">  983</span>&#160;        <span class="keywordflow">if</span> (rankIsUpper){</div>
<div class="line"><a name="l00984"></a><span class="lineno">  984</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#a57368529b2a7e76fec423cbfe9980b22">statevec_controlledUnitaryDistributed</a>(qureg,controlQubit,rot1,rot2,</div>
<div class="line"><a name="l00985"></a><span class="lineno">  985</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>, <span class="comment">//upper</span></div>
<div class="line"><a name="l00986"></a><span class="lineno">  986</span>&#160;                    qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">//lower</span></div>
<div class="line"><a name="l00987"></a><span class="lineno">  987</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>); <span class="comment">//output</span></div>
<div class="line"><a name="l00988"></a><span class="lineno">  988</span>&#160;        } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00989"></a><span class="lineno">  989</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#a57368529b2a7e76fec423cbfe9980b22">statevec_controlledUnitaryDistributed</a>(qureg,controlQubit,rot1,rot2,</div>
<div class="line"><a name="l00990"></a><span class="lineno">  990</span>&#160;                    qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">//upper</span></div>
<div class="line"><a name="l00991"></a><span class="lineno">  991</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>, <span class="comment">//lower</span></div>
<div class="line"><a name="l00992"></a><span class="lineno">  992</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>); <span class="comment">//output</span></div>
<div class="line"><a name="l00993"></a><span class="lineno">  993</span>&#160;        }</div>
<div class="line"><a name="l00994"></a><span class="lineno">  994</span>&#160;    }</div>
<div class="line"><a name="l00995"></a><span class="lineno">  995</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00227">chunkIsUpper()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00479">exchangeStateVectors()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00303">getChunkPairId()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00283">getRotAngleFromUnitaryMatrix()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00356">halfMatrixBlockFitsInChunk()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00224">Qureg::pairStateVec</a>, <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>, <a class="el" href="QuEST__cpu_8c_source.html#l02381">statevec_controlledUnitaryDistributed()</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l02241">statevec_controlledUnitaryLocal()</a>.</p>

</div>
</div>
<a id="abd509244d57657e148e4084c5ab5d28f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#abd509244d57657e148e4084c5ab5d28f">&#9670;&nbsp;</a></span>statevec_getImagAmp()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> statevec_getImagAmp </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long long int&#160;</td>
          <td class="paramname"><em>index</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00208">208</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00208"></a><span class="lineno">  208</span>&#160;                                                           {</div>
<div class="line"><a name="l00209"></a><span class="lineno">  209</span>&#160;    <span class="keywordtype">int</span> chunkId = <a class="code" href="QuEST__cpu__distributed_8c.html#a28be36627b2dd9a0da63dd6f60121b06">getChunkIdFromIndex</a>(qureg, index);</div>
<div class="line"><a name="l00210"></a><span class="lineno">  210</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> el; </div>
<div class="line"><a name="l00211"></a><span class="lineno">  211</span>&#160;    <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>==chunkId){</div>
<div class="line"><a name="l00212"></a><span class="lineno">  212</span>&#160;        el = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.imag[index-chunkId*qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>];</div>
<div class="line"><a name="l00213"></a><span class="lineno">  213</span>&#160;    }</div>
<div class="line"><a name="l00214"></a><span class="lineno">  214</span>&#160;    MPI_Bcast(&amp;el, 1, MPI_QuEST_REAL, chunkId, MPI_COMM_WORLD);</div>
<div class="line"><a name="l00215"></a><span class="lineno">  215</span>&#160;    <span class="keywordflow">return</span> el; </div>
<div class="line"><a name="l00216"></a><span class="lineno">  216</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00194">getChunkIdFromIndex()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>

</div>
</div>
<a id="abc9a9ef4344c7faaaf28ac25c76649b9"></a>
<h2 class="memtitle"><span class="permalink"><a href="#abc9a9ef4344c7faaaf28ac25c76649b9">&#9670;&nbsp;</a></span>statevec_getRealAmp()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> statevec_getRealAmp </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long long int&#160;</td>
          <td class="paramname"><em>index</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00198">198</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00198"></a><span class="lineno">  198</span>&#160;                                                           {</div>
<div class="line"><a name="l00199"></a><span class="lineno">  199</span>&#160;    <span class="keywordtype">int</span> chunkId = <a class="code" href="QuEST__cpu__distributed_8c.html#a28be36627b2dd9a0da63dd6f60121b06">getChunkIdFromIndex</a>(qureg, index);</div>
<div class="line"><a name="l00200"></a><span class="lineno">  200</span>&#160;    <a class="code" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a> el; </div>
<div class="line"><a name="l00201"></a><span class="lineno">  201</span>&#160;    <span class="keywordflow">if</span> (qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>==chunkId){</div>
<div class="line"><a name="l00202"></a><span class="lineno">  202</span>&#160;        el = qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>.real[index-chunkId*qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>];</div>
<div class="line"><a name="l00203"></a><span class="lineno">  203</span>&#160;    }</div>
<div class="line"><a name="l00204"></a><span class="lineno">  204</span>&#160;    MPI_Bcast(&amp;el, 1, MPI_QuEST_REAL, chunkId, MPI_COMM_WORLD);</div>
<div class="line"><a name="l00205"></a><span class="lineno">  205</span>&#160;    <span class="keywordflow">return</span> el; </div>
<div class="line"><a name="l00206"></a><span class="lineno">  206</span>&#160;} </div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00194">getChunkIdFromIndex()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a>, and <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>.</p>

</div>
</div>
<a id="af3fc7bd149c70f083b149050242cd55e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af3fc7bd149c70f083b149050242cd55e">&#9670;&nbsp;</a></span>statevec_hadamard()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_hadamard </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01206">1206</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01207"></a><span class="lineno"> 1207</span>&#160;{</div>
<div class="line"><a name="l01208"></a><span class="lineno"> 1208</span>&#160;    <span class="comment">// flag to require memory exchange. 1: an entire block fits on one rank, 0: at most half a block fits on one rank</span></div>
<div class="line"><a name="l01209"></a><span class="lineno"> 1209</span>&#160;    <span class="keywordtype">int</span> useLocalDataOnly = <a class="code" href="QuEST__cpu__distributed_8c.html#a4d043bb0cee54a5f94faf3ffc34a6790">halfMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01210"></a><span class="lineno"> 1210</span>&#160; </div>
<div class="line"><a name="l01211"></a><span class="lineno"> 1211</span>&#160;    <span class="comment">// rank&#39;s chunk is in upper half of block </span></div>
<div class="line"><a name="l01212"></a><span class="lineno"> 1212</span>&#160;    <span class="keywordtype">int</span> rankIsUpper;</div>
<div class="line"><a name="l01213"></a><span class="lineno"> 1213</span>&#160;    <span class="keywordtype">int</span> pairRank; <span class="comment">// rank of corresponding chunk</span></div>
<div class="line"><a name="l01214"></a><span class="lineno"> 1214</span>&#160; </div>
<div class="line"><a name="l01215"></a><span class="lineno"> 1215</span>&#160;    <span class="keywordflow">if</span> (useLocalDataOnly){</div>
<div class="line"><a name="l01216"></a><span class="lineno"> 1216</span>&#160;        <span class="comment">// all values required to update state vector lie in this rank</span></div>
<div class="line"><a name="l01217"></a><span class="lineno"> 1217</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#a86dbcc3db99294add9964741e19fbdab">statevec_hadamardLocal</a>(qureg, targetQubit);</div>
<div class="line"><a name="l01218"></a><span class="lineno"> 1218</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l01219"></a><span class="lineno"> 1219</span>&#160;        <span class="comment">// need to get corresponding chunk of state vector from other rank</span></div>
<div class="line"><a name="l01220"></a><span class="lineno"> 1220</span>&#160;        rankIsUpper = <a class="code" href="QuEST__cpu__distributed_8c.html#a0552889d6f57d9e0ed8b209bf426482d">chunkIsUpper</a>(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01221"></a><span class="lineno"> 1221</span>&#160;        pairRank = <a class="code" href="QuEST__cpu__distributed_8c.html#a7dba097f23f5d48dfdc9f3250444e2e4">getChunkPairId</a>(rankIsUpper, qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01222"></a><span class="lineno"> 1222</span>&#160;        <span class="comment">//printf(&quot;%d rank has pair rank: %d\n&quot;, qureg.rank, pairRank);</span></div>
<div class="line"><a name="l01223"></a><span class="lineno"> 1223</span>&#160;        <span class="comment">// get corresponding values from my pair</span></div>
<div class="line"><a name="l01224"></a><span class="lineno"> 1224</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#ae01c3eb75fd32de1a7e1dbc7a33a21e3">exchangeStateVectors</a>(qureg, pairRank);</div>
<div class="line"><a name="l01225"></a><span class="lineno"> 1225</span>&#160;        <span class="comment">// this rank&#39;s values are either in the upper of lower half of the block. send values to hadamardDistributed</span></div>
<div class="line"><a name="l01226"></a><span class="lineno"> 1226</span>&#160;        <span class="comment">// in the correct order</span></div>
<div class="line"><a name="l01227"></a><span class="lineno"> 1227</span>&#160;        <span class="keywordflow">if</span> (rankIsUpper){</div>
<div class="line"><a name="l01228"></a><span class="lineno"> 1228</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#abea6570b95fdfa102511ccd1fcb30685">statevec_hadamardDistributed</a>(qureg,</div>
<div class="line"><a name="l01229"></a><span class="lineno"> 1229</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>, <span class="comment">//upper</span></div>
<div class="line"><a name="l01230"></a><span class="lineno"> 1230</span>&#160;                    qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">//lower</span></div>
<div class="line"><a name="l01231"></a><span class="lineno"> 1231</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>, rankIsUpper); <span class="comment">//output</span></div>
<div class="line"><a name="l01232"></a><span class="lineno"> 1232</span>&#160;        } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l01233"></a><span class="lineno"> 1233</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#abea6570b95fdfa102511ccd1fcb30685">statevec_hadamardDistributed</a>(qureg,</div>
<div class="line"><a name="l01234"></a><span class="lineno"> 1234</span>&#160;                    qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">//upper</span></div>
<div class="line"><a name="l01235"></a><span class="lineno"> 1235</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>, <span class="comment">//lower</span></div>
<div class="line"><a name="l01236"></a><span class="lineno"> 1236</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>, rankIsUpper); <span class="comment">//output</span></div>
<div class="line"><a name="l01237"></a><span class="lineno"> 1237</span>&#160;        }</div>
<div class="line"><a name="l01238"></a><span class="lineno"> 1238</span>&#160;    }</div>
<div class="line"><a name="l01239"></a><span class="lineno"> 1239</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00227">chunkIsUpper()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00479">exchangeStateVectors()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00303">getChunkPairId()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00356">halfMatrixBlockFitsInChunk()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00224">Qureg::pairStateVec</a>, <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>, <a class="el" href="QuEST__cpu_8c_source.html#l02932">statevec_hadamardDistributed()</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l02872">statevec_hadamardLocal()</a>.</p>

</div>
</div>
<a id="a0acfe30083d0bc2a84da196378a36122"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a0acfe30083d0bc2a84da196378a36122">&#9670;&nbsp;</a></span>statevec_multiControlledMultiQubitUnitary()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_multiControlledMultiQubitUnitary </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long long int&#160;</td>
          <td class="paramname"><em>ctrlMask</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>targs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>numTargs</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplexMatrixN.html">ComplexMatrixN</a>&#160;</td>
          <td class="paramname"><em>u</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This calls swapQubitAmps only when it would involve a distributed communication; if the qubit chunks already fit in the node, it operates the unitary direct. </p>
<p>It is already gauranteed here that all target qubits can fit on each node (this is validated in the front-end)</p>
<p>@TODO: refactor so that the 'swap back' isn't performed; instead the qubit locations are updated. </p>

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01437">1437</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01437"></a><span class="lineno"> 1437</span>&#160;                                                                                                                                {</div>
<div class="line"><a name="l01438"></a><span class="lineno"> 1438</span>&#160; </div>
<div class="line"><a name="l01439"></a><span class="lineno"> 1439</span>&#160;    <span class="comment">// bit mask of target qubits (for quick collision checking)</span></div>
<div class="line"><a name="l01440"></a><span class="lineno"> 1440</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> targMask = <a class="code" href="QuEST__common_8c.html#acc45bb8300922ea5933e294921e25ea2">getQubitBitMask</a>(targs, numTargs);</div>
<div class="line"><a name="l01441"></a><span class="lineno"> 1441</span>&#160;    </div>
<div class="line"><a name="l01442"></a><span class="lineno"> 1442</span>&#160;    <span class="comment">// find lowest qubit available for swapping (isn&#39;t in targs)</span></div>
<div class="line"><a name="l01443"></a><span class="lineno"> 1443</span>&#160;    <span class="keywordtype">int</span> freeQb=0;</div>
<div class="line"><a name="l01444"></a><span class="lineno"> 1444</span>&#160;    <span class="keywordflow">while</span> (<a class="code" href="QuEST__cpu__internal_8h.html#ae94d012c3da6c84599e99f6afea81f5f">maskContainsBit</a>(targMask, freeQb))</div>
<div class="line"><a name="l01445"></a><span class="lineno"> 1445</span>&#160;        freeQb++;</div>
<div class="line"><a name="l01446"></a><span class="lineno"> 1446</span>&#160;        </div>
<div class="line"><a name="l01447"></a><span class="lineno"> 1447</span>&#160;    <span class="comment">// assign indices of where each target will be swapped to (else itself)</span></div>
<div class="line"><a name="l01448"></a><span class="lineno"> 1448</span>&#160;    <span class="keywordtype">int</span> swapTargs[numTargs];</div>
<div class="line"><a name="l01449"></a><span class="lineno"> 1449</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> t=0; t&lt;numTargs; t++) {</div>
<div class="line"><a name="l01450"></a><span class="lineno"> 1450</span>&#160;        <span class="keywordflow">if</span> (<a class="code" href="QuEST__cpu__distributed_8c.html#a4d043bb0cee54a5f94faf3ffc34a6790">halfMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targs[t]))</div>
<div class="line"><a name="l01451"></a><span class="lineno"> 1451</span>&#160;            swapTargs[t] = targs[t];</div>
<div class="line"><a name="l01452"></a><span class="lineno"> 1452</span>&#160;        <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l01453"></a><span class="lineno"> 1453</span>&#160;            <span class="comment">// mark swap</span></div>
<div class="line"><a name="l01454"></a><span class="lineno"> 1454</span>&#160;            swapTargs[t] = freeQb;</div>
<div class="line"><a name="l01455"></a><span class="lineno"> 1455</span>&#160;            </div>
<div class="line"><a name="l01456"></a><span class="lineno"> 1456</span>&#160;            <span class="comment">// update ctrlMask if swapped-out qubit was a control</span></div>
<div class="line"><a name="l01457"></a><span class="lineno"> 1457</span>&#160;            <span class="keywordflow">if</span> (<a class="code" href="QuEST__cpu__internal_8h.html#ae94d012c3da6c84599e99f6afea81f5f">maskContainsBit</a>(ctrlMask, swapTargs[t]))</div>
<div class="line"><a name="l01458"></a><span class="lineno"> 1458</span>&#160;                ctrlMask = <a class="code" href="QuEST__gpu_8cu.html#ae1b7788cf504ec3d79de3855f97929c7">flipBit</a>(<a class="code" href="QuEST__gpu_8cu.html#ae1b7788cf504ec3d79de3855f97929c7">flipBit</a>(ctrlMask, swapTargs[t]), targs[t]); <span class="comment">// swap targ and ctrl</span></div>
<div class="line"><a name="l01459"></a><span class="lineno"> 1459</span>&#160;            </div>
<div class="line"><a name="l01460"></a><span class="lineno"> 1460</span>&#160;            <span class="comment">// locate next available on-chunk qubit</span></div>
<div class="line"><a name="l01461"></a><span class="lineno"> 1461</span>&#160;            freeQb++;</div>
<div class="line"><a name="l01462"></a><span class="lineno"> 1462</span>&#160;            <span class="keywordflow">while</span> (<a class="code" href="QuEST__cpu__internal_8h.html#ae94d012c3da6c84599e99f6afea81f5f">maskContainsBit</a>(targMask, freeQb))</div>
<div class="line"><a name="l01463"></a><span class="lineno"> 1463</span>&#160;                freeQb++;</div>
<div class="line"><a name="l01464"></a><span class="lineno"> 1464</span>&#160;        }</div>
<div class="line"><a name="l01465"></a><span class="lineno"> 1465</span>&#160;    }</div>
<div class="line"><a name="l01466"></a><span class="lineno"> 1466</span>&#160;    </div>
<div class="line"><a name="l01467"></a><span class="lineno"> 1467</span>&#160;    <span class="comment">// perform swaps as necessary </span></div>
<div class="line"><a name="l01468"></a><span class="lineno"> 1468</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> t=0; t&lt;numTargs; t++)</div>
<div class="line"><a name="l01469"></a><span class="lineno"> 1469</span>&#160;        <span class="keywordflow">if</span> (swapTargs[t] != targs[t])</div>
<div class="line"><a name="l01470"></a><span class="lineno"> 1470</span>&#160;            <a class="code" href="QuEST__cpu__distributed_8c.html#ab7478fcaf6357ab202d72853b672e375">statevec_swapQubitAmps</a>(qureg, targs[t], swapTargs[t]);</div>
<div class="line"><a name="l01471"></a><span class="lineno"> 1471</span>&#160;    </div>
<div class="line"><a name="l01472"></a><span class="lineno"> 1472</span>&#160;    <span class="comment">// all target qubits have now been swapped into local memory</span></div>
<div class="line"><a name="l01473"></a><span class="lineno"> 1473</span>&#160;    <a class="code" href="QuEST__cpu_8c.html#a0aedcccfa50c7aaa8b7fc4c14d7cdfb8">statevec_multiControlledMultiQubitUnitaryLocal</a>(qureg, ctrlMask, swapTargs, numTargs, u);</div>
<div class="line"><a name="l01474"></a><span class="lineno"> 1474</span>&#160;    </div>
<div class="line"><a name="l01475"></a><span class="lineno"> 1475</span>&#160;    <span class="comment">// undo swaps </span></div>
<div class="line"><a name="l01476"></a><span class="lineno"> 1476</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> t=0; t&lt;numTargs; t++)</div>
<div class="line"><a name="l01477"></a><span class="lineno"> 1477</span>&#160;        <span class="keywordflow">if</span> (swapTargs[t] != targs[t])</div>
<div class="line"><a name="l01478"></a><span class="lineno"> 1478</span>&#160;            <a class="code" href="QuEST__cpu__distributed_8c.html#ab7478fcaf6357ab202d72853b672e375">statevec_swapQubitAmps</a>(qureg, targs[t], swapTargs[t]);</div>
<div class="line"><a name="l01479"></a><span class="lineno"> 1479</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__gpu_8cu_source.html#l00095">flipBit()</a>, <a class="el" href="QuEST__common_8c_source.html#l00044">getQubitBitMask()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00356">halfMatrixBlockFitsInChunk()</a>, <a class="el" href="QuEST__cpu__internal_8h_source.html#l00034">maskContainsBit()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST__cpu_8c_source.html#l01846">statevec_multiControlledMultiQubitUnitaryLocal()</a>, and <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01354">statevec_swapQubitAmps()</a>.</p>

</div>
</div>
<a id="affbd18d7c2ed8d5bd5edb67116501145"></a>
<h2 class="memtitle"><span class="permalink"><a href="#affbd18d7c2ed8d5bd5edb67116501145">&#9670;&nbsp;</a></span>statevec_multiControlledTwoQubitUnitary()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_multiControlledTwoQubitUnitary </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long long int&#160;</td>
          <td class="paramname"><em>ctrlMask</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>q1</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>q2</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplexMatrix4.html">ComplexMatrix4</a>&#160;</td>
          <td class="paramname"><em>u</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This calls swapQubitAmps only when it would involve a distributed communication; if the qubit chunks already fit in the node, it operates the unitary direct. </p>
<p>Note the order of q1 and q2 in the call to twoQubitUnitaryLocal is important.</p>
<p>@TODO: refactor so that the 'swap back' isn't performed; instead the qubit locations are updated. @TODO: the double swap (q1,q2 to 0,1) may be possible simultaneously by a bespoke swap routine. </p>

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01381">1381</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01381"></a><span class="lineno"> 1381</span>&#160;                                                                                                                    {</div>
<div class="line"><a name="l01382"></a><span class="lineno"> 1382</span>&#160;    <span class="keywordtype">int</span> q1FitsInNode = <a class="code" href="QuEST__cpu__distributed_8c.html#a4d043bb0cee54a5f94faf3ffc34a6790">halfMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, q1);</div>
<div class="line"><a name="l01383"></a><span class="lineno"> 1383</span>&#160;    <span class="keywordtype">int</span> q2FitsInNode = <a class="code" href="QuEST__cpu__distributed_8c.html#a4d043bb0cee54a5f94faf3ffc34a6790">halfMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, q2);</div>
<div class="line"><a name="l01384"></a><span class="lineno"> 1384</span>&#160;        </div>
<div class="line"><a name="l01385"></a><span class="lineno"> 1385</span>&#160;    <span class="keywordflow">if</span> (q1FitsInNode &amp;&amp; q2FitsInNode) {    </div>
<div class="line"><a name="l01386"></a><span class="lineno"> 1386</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#af8236a00389137b5eff986a40577eaf3">statevec_multiControlledTwoQubitUnitaryLocal</a>(qureg, ctrlMask, q1, q2, u);</div>
<div class="line"><a name="l01387"></a><span class="lineno"> 1387</span>&#160;        </div>
<div class="line"><a name="l01388"></a><span class="lineno"> 1388</span>&#160;    } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (q1FitsInNode) {</div>
<div class="line"><a name="l01389"></a><span class="lineno"> 1389</span>&#160;        <span class="keywordtype">int</span> qSwap = (q1 &gt; 0)? q1-1 : q1+1;</div>
<div class="line"><a name="l01390"></a><span class="lineno"> 1390</span>&#160; </div>
<div class="line"><a name="l01391"></a><span class="lineno"> 1391</span>&#160;        <span class="comment">// ensure ctrl == qSwap, ensure ctrlMask updates under the swap</span></div>
<div class="line"><a name="l01392"></a><span class="lineno"> 1392</span>&#160;        <span class="keywordflow">if</span> (<a class="code" href="QuEST__cpu__internal_8h.html#ae94d012c3da6c84599e99f6afea81f5f">maskContainsBit</a>(ctrlMask, qSwap))</div>
<div class="line"><a name="l01393"></a><span class="lineno"> 1393</span>&#160;            ctrlMask = <a class="code" href="QuEST__gpu_8cu.html#ae1b7788cf504ec3d79de3855f97929c7">flipBit</a>(<a class="code" href="QuEST__gpu_8cu.html#ae1b7788cf504ec3d79de3855f97929c7">flipBit</a>(ctrlMask, q2), qSwap);</div>
<div class="line"><a name="l01394"></a><span class="lineno"> 1394</span>&#160; </div>
<div class="line"><a name="l01395"></a><span class="lineno"> 1395</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#ab7478fcaf6357ab202d72853b672e375">statevec_swapQubitAmps</a>(qureg, q2, qSwap);</div>
<div class="line"><a name="l01396"></a><span class="lineno"> 1396</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#af8236a00389137b5eff986a40577eaf3">statevec_multiControlledTwoQubitUnitaryLocal</a>(qureg, ctrlMask, q1, qSwap, u);</div>
<div class="line"><a name="l01397"></a><span class="lineno"> 1397</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#ab7478fcaf6357ab202d72853b672e375">statevec_swapQubitAmps</a>(qureg, q2, qSwap);</div>
<div class="line"><a name="l01398"></a><span class="lineno"> 1398</span>&#160; </div>
<div class="line"><a name="l01399"></a><span class="lineno"> 1399</span>&#160;    } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (q2FitsInNode) {</div>
<div class="line"><a name="l01400"></a><span class="lineno"> 1400</span>&#160;        <span class="keywordtype">int</span> qSwap = (q2 &gt; 0)? q2-1 : q2+1;</div>
<div class="line"><a name="l01401"></a><span class="lineno"> 1401</span>&#160;        </div>
<div class="line"><a name="l01402"></a><span class="lineno"> 1402</span>&#160;        <span class="comment">// ensure ctrl == qSwap, ensure ctrlMask updates under the swap</span></div>
<div class="line"><a name="l01403"></a><span class="lineno"> 1403</span>&#160;        <span class="keywordflow">if</span> (<a class="code" href="QuEST__cpu__internal_8h.html#ae94d012c3da6c84599e99f6afea81f5f">maskContainsBit</a>(ctrlMask, qSwap))</div>
<div class="line"><a name="l01404"></a><span class="lineno"> 1404</span>&#160;            ctrlMask = <a class="code" href="QuEST__gpu_8cu.html#ae1b7788cf504ec3d79de3855f97929c7">flipBit</a>(<a class="code" href="QuEST__gpu_8cu.html#ae1b7788cf504ec3d79de3855f97929c7">flipBit</a>(ctrlMask, q1), qSwap);</div>
<div class="line"><a name="l01405"></a><span class="lineno"> 1405</span>&#160;        </div>
<div class="line"><a name="l01406"></a><span class="lineno"> 1406</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#ab7478fcaf6357ab202d72853b672e375">statevec_swapQubitAmps</a>(qureg, q1, qSwap);</div>
<div class="line"><a name="l01407"></a><span class="lineno"> 1407</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#af8236a00389137b5eff986a40577eaf3">statevec_multiControlledTwoQubitUnitaryLocal</a>(qureg, ctrlMask, qSwap, q2, u);</div>
<div class="line"><a name="l01408"></a><span class="lineno"> 1408</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#ab7478fcaf6357ab202d72853b672e375">statevec_swapQubitAmps</a>(qureg, q1, qSwap);</div>
<div class="line"><a name="l01409"></a><span class="lineno"> 1409</span>&#160;        </div>
<div class="line"><a name="l01410"></a><span class="lineno"> 1410</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l01411"></a><span class="lineno"> 1411</span>&#160;        <span class="comment">// we know with certainty that both q1 and q2 &gt;= 2</span></div>
<div class="line"><a name="l01412"></a><span class="lineno"> 1412</span>&#160;        <span class="keywordtype">int</span> swap1 = 0;</div>
<div class="line"><a name="l01413"></a><span class="lineno"> 1413</span>&#160;        <span class="keywordtype">int</span> swap2 = 1;</div>
<div class="line"><a name="l01414"></a><span class="lineno"> 1414</span>&#160;        </div>
<div class="line"><a name="l01415"></a><span class="lineno"> 1415</span>&#160;        <span class="comment">// if ctrl == swap1 or swap2, ensure ctrlMask updates under the swap</span></div>
<div class="line"><a name="l01416"></a><span class="lineno"> 1416</span>&#160;        <span class="keywordflow">if</span> (<a class="code" href="QuEST__cpu__internal_8h.html#ae94d012c3da6c84599e99f6afea81f5f">maskContainsBit</a>(ctrlMask, swap1))</div>
<div class="line"><a name="l01417"></a><span class="lineno"> 1417</span>&#160;            ctrlMask = <a class="code" href="QuEST__gpu_8cu.html#ae1b7788cf504ec3d79de3855f97929c7">flipBit</a>(<a class="code" href="QuEST__gpu_8cu.html#ae1b7788cf504ec3d79de3855f97929c7">flipBit</a>(ctrlMask, swap1), q1);</div>
<div class="line"><a name="l01418"></a><span class="lineno"> 1418</span>&#160;        <span class="keywordflow">if</span> (<a class="code" href="QuEST__cpu__internal_8h.html#ae94d012c3da6c84599e99f6afea81f5f">maskContainsBit</a>(ctrlMask, swap2))</div>
<div class="line"><a name="l01419"></a><span class="lineno"> 1419</span>&#160;            ctrlMask = <a class="code" href="QuEST__gpu_8cu.html#ae1b7788cf504ec3d79de3855f97929c7">flipBit</a>(<a class="code" href="QuEST__gpu_8cu.html#ae1b7788cf504ec3d79de3855f97929c7">flipBit</a>(ctrlMask, swap2), q2);</div>
<div class="line"><a name="l01420"></a><span class="lineno"> 1420</span>&#160;        </div>
<div class="line"><a name="l01421"></a><span class="lineno"> 1421</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#ab7478fcaf6357ab202d72853b672e375">statevec_swapQubitAmps</a>(qureg, q1, swap1);</div>
<div class="line"><a name="l01422"></a><span class="lineno"> 1422</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#ab7478fcaf6357ab202d72853b672e375">statevec_swapQubitAmps</a>(qureg, q2, swap2);</div>
<div class="line"><a name="l01423"></a><span class="lineno"> 1423</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#af8236a00389137b5eff986a40577eaf3">statevec_multiControlledTwoQubitUnitaryLocal</a>(qureg, ctrlMask, swap1, swap2, u);</div>
<div class="line"><a name="l01424"></a><span class="lineno"> 1424</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#ab7478fcaf6357ab202d72853b672e375">statevec_swapQubitAmps</a>(qureg, q1, swap1);</div>
<div class="line"><a name="l01425"></a><span class="lineno"> 1425</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#ab7478fcaf6357ab202d72853b672e375">statevec_swapQubitAmps</a>(qureg, q2, swap2);</div>
<div class="line"><a name="l01426"></a><span class="lineno"> 1426</span>&#160;    }</div>
<div class="line"><a name="l01427"></a><span class="lineno"> 1427</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__gpu_8cu_source.html#l00095">flipBit()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00356">halfMatrixBlockFitsInChunk()</a>, <a class="el" href="QuEST__cpu__internal_8h_source.html#l00034">maskContainsBit()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST__cpu_8c_source.html#l01747">statevec_multiControlledTwoQubitUnitaryLocal()</a>, and <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01354">statevec_swapQubitAmps()</a>.</p>

</div>
</div>
<a id="a600bda10463e2078ce746ec28f2d39c9"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a600bda10463e2078ce746ec28f2d39c9">&#9670;&nbsp;</a></span>statevec_multiControlledUnitary()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_multiControlledUnitary </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long long int&#160;</td>
          <td class="paramname"><em>ctrlQubitsMask</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">long long int&#160;</td>
          <td class="paramname"><em>ctrlFlipMask</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplexMatrix2.html">ComplexMatrix2</a>&#160;</td>
          <td class="paramname"><em>u</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00997">997</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00998"></a><span class="lineno">  998</span>&#160;{</div>
<div class="line"><a name="l00999"></a><span class="lineno">  999</span>&#160;    <span class="comment">// flag to require memory exchange. 1: an entire block fits on one rank, 0: at most half a block fits on one rank</span></div>
<div class="line"><a name="l01000"></a><span class="lineno"> 1000</span>&#160;    <span class="keywordtype">int</span> useLocalDataOnly = <a class="code" href="QuEST__cpu__distributed_8c.html#a4d043bb0cee54a5f94faf3ffc34a6790">halfMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01001"></a><span class="lineno"> 1001</span>&#160;    <a class="code" href="structComplex.html">Complex</a> rot1, rot2;</div>
<div class="line"><a name="l01002"></a><span class="lineno"> 1002</span>&#160; </div>
<div class="line"><a name="l01003"></a><span class="lineno"> 1003</span>&#160;    <span class="comment">// rank&#39;s chunk is in upper half of block </span></div>
<div class="line"><a name="l01004"></a><span class="lineno"> 1004</span>&#160;    <span class="keywordtype">int</span> rankIsUpper;</div>
<div class="line"><a name="l01005"></a><span class="lineno"> 1005</span>&#160;    <span class="keywordtype">int</span> pairRank; <span class="comment">// rank of corresponding chunk</span></div>
<div class="line"><a name="l01006"></a><span class="lineno"> 1006</span>&#160; </div>
<div class="line"><a name="l01007"></a><span class="lineno"> 1007</span>&#160;    <span class="keywordflow">if</span> (useLocalDataOnly){</div>
<div class="line"><a name="l01008"></a><span class="lineno"> 1008</span>&#160;        <span class="comment">// all values required to update state vector lie in this rank</span></div>
<div class="line"><a name="l01009"></a><span class="lineno"> 1009</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#ab19f28e68330da68ea3caa2bdef32da9">statevec_multiControlledUnitaryLocal</a>(qureg, targetQubit, ctrlQubitsMask, ctrlFlipMask, u);</div>
<div class="line"><a name="l01010"></a><span class="lineno"> 1010</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l01011"></a><span class="lineno"> 1011</span>&#160;        <span class="comment">// need to get corresponding chunk of state vector from other rank</span></div>
<div class="line"><a name="l01012"></a><span class="lineno"> 1012</span>&#160;        rankIsUpper = <a class="code" href="QuEST__cpu__distributed_8c.html#a0552889d6f57d9e0ed8b209bf426482d">chunkIsUpper</a>(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01013"></a><span class="lineno"> 1013</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#a5c9b2f129bdffaaba9857f6eddecbb17">getRotAngleFromUnitaryMatrix</a>(rankIsUpper, &amp;rot1, &amp;rot2, u);</div>
<div class="line"><a name="l01014"></a><span class="lineno"> 1014</span>&#160;        pairRank = <a class="code" href="QuEST__cpu__distributed_8c.html#a7dba097f23f5d48dfdc9f3250444e2e4">getChunkPairId</a>(rankIsUpper, qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01015"></a><span class="lineno"> 1015</span>&#160; </div>
<div class="line"><a name="l01016"></a><span class="lineno"> 1016</span>&#160;        <span class="comment">// get corresponding values from my pair</span></div>
<div class="line"><a name="l01017"></a><span class="lineno"> 1017</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#ae01c3eb75fd32de1a7e1dbc7a33a21e3">exchangeStateVectors</a>(qureg, pairRank);</div>
<div class="line"><a name="l01018"></a><span class="lineno"> 1018</span>&#160; </div>
<div class="line"><a name="l01019"></a><span class="lineno"> 1019</span>&#160;        <span class="comment">// this rank&#39;s values are either in the upper of lower half of the block. send values to multiControlledUnitaryDistributed</span></div>
<div class="line"><a name="l01020"></a><span class="lineno"> 1020</span>&#160;        <span class="comment">// in the correct order</span></div>
<div class="line"><a name="l01021"></a><span class="lineno"> 1021</span>&#160;        <span class="keywordflow">if</span> (rankIsUpper){</div>
<div class="line"><a name="l01022"></a><span class="lineno"> 1022</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#ab58fe4be895283c2c4eb86ec9af5682e">statevec_multiControlledUnitaryDistributed</a>(qureg,targetQubit,ctrlQubitsMask,ctrlFlipMask,rot1,rot2,</div>
<div class="line"><a name="l01023"></a><span class="lineno"> 1023</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>, <span class="comment">//upper</span></div>
<div class="line"><a name="l01024"></a><span class="lineno"> 1024</span>&#160;                    qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">//lower</span></div>
<div class="line"><a name="l01025"></a><span class="lineno"> 1025</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>); <span class="comment">//output</span></div>
<div class="line"><a name="l01026"></a><span class="lineno"> 1026</span>&#160;        } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l01027"></a><span class="lineno"> 1027</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#ab58fe4be895283c2c4eb86ec9af5682e">statevec_multiControlledUnitaryDistributed</a>(qureg,targetQubit,ctrlQubitsMask,ctrlFlipMask,rot1,rot2,</div>
<div class="line"><a name="l01028"></a><span class="lineno"> 1028</span>&#160;                    qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">//upper</span></div>
<div class="line"><a name="l01029"></a><span class="lineno"> 1029</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>, <span class="comment">//lower</span></div>
<div class="line"><a name="l01030"></a><span class="lineno"> 1030</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>); <span class="comment">//output</span></div>
<div class="line"><a name="l01031"></a><span class="lineno"> 1031</span>&#160;        }</div>
<div class="line"><a name="l01032"></a><span class="lineno"> 1032</span>&#160;    }</div>
<div class="line"><a name="l01033"></a><span class="lineno"> 1033</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00227">chunkIsUpper()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00479">exchangeStateVectors()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00303">getChunkPairId()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00283">getRotAngleFromUnitaryMatrix()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00356">halfMatrixBlockFitsInChunk()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00224">Qureg::pairStateVec</a>, <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>, <a class="el" href="QuEST__cpu_8c_source.html#l02447">statevec_multiControlledUnitaryDistributed()</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l02173">statevec_multiControlledUnitaryLocal()</a>.</p>

</div>
</div>
<a id="a1c82b5e914a8a39c5c7b782dbc16fa76"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a1c82b5e914a8a39c5c7b782dbc16fa76">&#9670;&nbsp;</a></span>statevec_pauliX()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_pauliX </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01034">1034</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01035"></a><span class="lineno"> 1035</span>&#160;{</div>
<div class="line"><a name="l01036"></a><span class="lineno"> 1036</span>&#160;    <span class="comment">// flag to require memory exchange. 1: an entire block fits on one rank, 0: at most half a block fits on one rank</span></div>
<div class="line"><a name="l01037"></a><span class="lineno"> 1037</span>&#160;    <span class="keywordtype">int</span> useLocalDataOnly = <a class="code" href="QuEST__cpu__distributed_8c.html#a4d043bb0cee54a5f94faf3ffc34a6790">halfMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01038"></a><span class="lineno"> 1038</span>&#160; </div>
<div class="line"><a name="l01039"></a><span class="lineno"> 1039</span>&#160;    <span class="comment">// rank&#39;s chunk is in upper half of block </span></div>
<div class="line"><a name="l01040"></a><span class="lineno"> 1040</span>&#160;    <span class="keywordtype">int</span> rankIsUpper;</div>
<div class="line"><a name="l01041"></a><span class="lineno"> 1041</span>&#160;    <span class="keywordtype">int</span> pairRank; <span class="comment">// rank of corresponding chunk</span></div>
<div class="line"><a name="l01042"></a><span class="lineno"> 1042</span>&#160; </div>
<div class="line"><a name="l01043"></a><span class="lineno"> 1043</span>&#160;    <span class="keywordflow">if</span> (useLocalDataOnly){</div>
<div class="line"><a name="l01044"></a><span class="lineno"> 1044</span>&#160;        <span class="comment">// all values required to update state vector lie in this rank</span></div>
<div class="line"><a name="l01045"></a><span class="lineno"> 1045</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#aa987d1e0ba97da2ca540194356dd62de">statevec_pauliXLocal</a>(qureg, targetQubit);</div>
<div class="line"><a name="l01046"></a><span class="lineno"> 1046</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l01047"></a><span class="lineno"> 1047</span>&#160;        <span class="comment">// need to get corresponding chunk of state vector from other rank</span></div>
<div class="line"><a name="l01048"></a><span class="lineno"> 1048</span>&#160;        rankIsUpper = <a class="code" href="QuEST__cpu__distributed_8c.html#a0552889d6f57d9e0ed8b209bf426482d">chunkIsUpper</a>(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01049"></a><span class="lineno"> 1049</span>&#160;        pairRank = <a class="code" href="QuEST__cpu__distributed_8c.html#a7dba097f23f5d48dfdc9f3250444e2e4">getChunkPairId</a>(rankIsUpper, qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01050"></a><span class="lineno"> 1050</span>&#160;        <span class="comment">//printf(&quot;%d rank has pair rank: %d\n&quot;, qureg.rank, pairRank);</span></div>
<div class="line"><a name="l01051"></a><span class="lineno"> 1051</span>&#160;        <span class="comment">// get corresponding values from my pair</span></div>
<div class="line"><a name="l01052"></a><span class="lineno"> 1052</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#ae01c3eb75fd32de1a7e1dbc7a33a21e3">exchangeStateVectors</a>(qureg, pairRank);</div>
<div class="line"><a name="l01053"></a><span class="lineno"> 1053</span>&#160;        <span class="comment">// this rank&#39;s values are either in the upper of lower half of the block. pauliX just replaces</span></div>
<div class="line"><a name="l01054"></a><span class="lineno"> 1054</span>&#160;        <span class="comment">// this rank&#39;s values with pair values</span></div>
<div class="line"><a name="l01055"></a><span class="lineno"> 1055</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#a464efbd1d7ca5a7b25c83ada001955c2">statevec_pauliXDistributed</a>(qureg,</div>
<div class="line"><a name="l01056"></a><span class="lineno"> 1056</span>&#160;                qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">// in</span></div>
<div class="line"><a name="l01057"></a><span class="lineno"> 1057</span>&#160;                qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>); <span class="comment">// out</span></div>
<div class="line"><a name="l01058"></a><span class="lineno"> 1058</span>&#160;    }</div>
<div class="line"><a name="l01059"></a><span class="lineno"> 1059</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00227">chunkIsUpper()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00479">exchangeStateVectors()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00303">getChunkPairId()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00356">halfMatrixBlockFitsInChunk()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00224">Qureg::pairStateVec</a>, <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>, <a class="el" href="QuEST__cpu_8c_source.html#l02556">statevec_pauliXDistributed()</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l02498">statevec_pauliXLocal()</a>.</p>

</div>
</div>
<a id="af1cca787f3b0e0c91ffb2495f9ad8d5a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af1cca787f3b0e0c91ffb2495f9ad8d5a">&#9670;&nbsp;</a></span>statevec_pauliY()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_pauliY </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01090">1090</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01091"></a><span class="lineno"> 1091</span>&#160;{       </div>
<div class="line"><a name="l01092"></a><span class="lineno"> 1092</span>&#160;        <span class="keywordtype">int</span> conjFac = 1;</div>
<div class="line"><a name="l01093"></a><span class="lineno"> 1093</span>&#160; </div>
<div class="line"><a name="l01094"></a><span class="lineno"> 1094</span>&#160;    <span class="comment">// flag to require memory exchange. 1: an entire block fits on one rank, 0: at most half a block fits on one rank</span></div>
<div class="line"><a name="l01095"></a><span class="lineno"> 1095</span>&#160;    <span class="keywordtype">int</span> useLocalDataOnly = <a class="code" href="QuEST__cpu__distributed_8c.html#a4d043bb0cee54a5f94faf3ffc34a6790">halfMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01096"></a><span class="lineno"> 1096</span>&#160;    <span class="keywordtype">int</span> rankIsUpper;    <span class="comment">// rank&#39;s chunk is in upper half of block </span></div>
<div class="line"><a name="l01097"></a><span class="lineno"> 1097</span>&#160;    <span class="keywordtype">int</span> pairRank;               <span class="comment">// rank of corresponding chunk</span></div>
<div class="line"><a name="l01098"></a><span class="lineno"> 1098</span>&#160; </div>
<div class="line"><a name="l01099"></a><span class="lineno"> 1099</span>&#160;    <span class="keywordflow">if</span> (useLocalDataOnly){</div>
<div class="line"><a name="l01100"></a><span class="lineno"> 1100</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#a45b0916c3e121837f214b64f7424e479">statevec_pauliYLocal</a>(qureg, targetQubit, conjFac);</div>
<div class="line"><a name="l01101"></a><span class="lineno"> 1101</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l01102"></a><span class="lineno"> 1102</span>&#160;        <span class="comment">// need to get corresponding chunk of state vector from other rank</span></div>
<div class="line"><a name="l01103"></a><span class="lineno"> 1103</span>&#160;        rankIsUpper = <a class="code" href="QuEST__cpu__distributed_8c.html#a0552889d6f57d9e0ed8b209bf426482d">chunkIsUpper</a>(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01104"></a><span class="lineno"> 1104</span>&#160;        pairRank = <a class="code" href="QuEST__cpu__distributed_8c.html#a7dba097f23f5d48dfdc9f3250444e2e4">getChunkPairId</a>(rankIsUpper, qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01105"></a><span class="lineno"> 1105</span>&#160;        <span class="comment">// get corresponding values from my pair</span></div>
<div class="line"><a name="l01106"></a><span class="lineno"> 1106</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#ae01c3eb75fd32de1a7e1dbc7a33a21e3">exchangeStateVectors</a>(qureg, pairRank);</div>
<div class="line"><a name="l01107"></a><span class="lineno"> 1107</span>&#160;        <span class="comment">// this rank&#39;s values are either in the upper of lower half of the block</span></div>
<div class="line"><a name="l01108"></a><span class="lineno"> 1108</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#a0f562af6cb665a8a7a3f80e9449734d5">statevec_pauliYDistributed</a>(qureg,</div>
<div class="line"><a name="l01109"></a><span class="lineno"> 1109</span>&#160;                qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">// in</span></div>
<div class="line"><a name="l01110"></a><span class="lineno"> 1110</span>&#160;                qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>, <span class="comment">// out</span></div>
<div class="line"><a name="l01111"></a><span class="lineno"> 1111</span>&#160;                rankIsUpper, conjFac);</div>
<div class="line"><a name="l01112"></a><span class="lineno"> 1112</span>&#160;    }</div>
<div class="line"><a name="l01113"></a><span class="lineno"> 1113</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00227">chunkIsUpper()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00479">exchangeStateVectors()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00303">getChunkPairId()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00356">halfMatrixBlockFitsInChunk()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00224">Qureg::pairStateVec</a>, <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>, <a class="el" href="QuEST__cpu_8c_source.html#l02739">statevec_pauliYDistributed()</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l02682">statevec_pauliYLocal()</a>.</p>

</div>
</div>
<a id="a81fbd2eccd0d0e5a3cece4df2f96cb92"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a81fbd2eccd0d0e5a3cece4df2f96cb92">&#9670;&nbsp;</a></span>statevec_pauliYConj()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_pauliYConj </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01115">1115</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01116"></a><span class="lineno"> 1116</span>&#160;{       </div>
<div class="line"><a name="l01117"></a><span class="lineno"> 1117</span>&#160;        <span class="keywordtype">int</span> conjFac = -1;</div>
<div class="line"><a name="l01118"></a><span class="lineno"> 1118</span>&#160; </div>
<div class="line"><a name="l01119"></a><span class="lineno"> 1119</span>&#160;    <span class="comment">// flag to require memory exchange. 1: an entire block fits on one rank, 0: at most half a block fits on one rank</span></div>
<div class="line"><a name="l01120"></a><span class="lineno"> 1120</span>&#160;    <span class="keywordtype">int</span> useLocalDataOnly = <a class="code" href="QuEST__cpu__distributed_8c.html#a4d043bb0cee54a5f94faf3ffc34a6790">halfMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01121"></a><span class="lineno"> 1121</span>&#160;    <span class="keywordtype">int</span> rankIsUpper;    <span class="comment">// rank&#39;s chunk is in upper half of block </span></div>
<div class="line"><a name="l01122"></a><span class="lineno"> 1122</span>&#160;    <span class="keywordtype">int</span> pairRank;               <span class="comment">// rank of corresponding chunk</span></div>
<div class="line"><a name="l01123"></a><span class="lineno"> 1123</span>&#160; </div>
<div class="line"><a name="l01124"></a><span class="lineno"> 1124</span>&#160;    <span class="keywordflow">if</span> (useLocalDataOnly){</div>
<div class="line"><a name="l01125"></a><span class="lineno"> 1125</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#a45b0916c3e121837f214b64f7424e479">statevec_pauliYLocal</a>(qureg, targetQubit, conjFac);</div>
<div class="line"><a name="l01126"></a><span class="lineno"> 1126</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l01127"></a><span class="lineno"> 1127</span>&#160;        <span class="comment">// need to get corresponding chunk of state vector from other rank</span></div>
<div class="line"><a name="l01128"></a><span class="lineno"> 1128</span>&#160;        rankIsUpper = <a class="code" href="QuEST__cpu__distributed_8c.html#a0552889d6f57d9e0ed8b209bf426482d">chunkIsUpper</a>(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01129"></a><span class="lineno"> 1129</span>&#160;        pairRank = <a class="code" href="QuEST__cpu__distributed_8c.html#a7dba097f23f5d48dfdc9f3250444e2e4">getChunkPairId</a>(rankIsUpper, qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l01130"></a><span class="lineno"> 1130</span>&#160;        <span class="comment">// get corresponding values from my pair</span></div>
<div class="line"><a name="l01131"></a><span class="lineno"> 1131</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#ae01c3eb75fd32de1a7e1dbc7a33a21e3">exchangeStateVectors</a>(qureg, pairRank);</div>
<div class="line"><a name="l01132"></a><span class="lineno"> 1132</span>&#160;        <span class="comment">// this rank&#39;s values are either in the upper of lower half of the block</span></div>
<div class="line"><a name="l01133"></a><span class="lineno"> 1133</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#a0f562af6cb665a8a7a3f80e9449734d5">statevec_pauliYDistributed</a>(qureg,</div>
<div class="line"><a name="l01134"></a><span class="lineno"> 1134</span>&#160;                qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">// in</span></div>
<div class="line"><a name="l01135"></a><span class="lineno"> 1135</span>&#160;                qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>, <span class="comment">// out</span></div>
<div class="line"><a name="l01136"></a><span class="lineno"> 1136</span>&#160;                rankIsUpper, conjFac);</div>
<div class="line"><a name="l01137"></a><span class="lineno"> 1137</span>&#160;    }</div>
<div class="line"><a name="l01138"></a><span class="lineno"> 1138</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00227">chunkIsUpper()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00479">exchangeStateVectors()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00303">getChunkPairId()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00356">halfMatrixBlockFitsInChunk()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00224">Qureg::pairStateVec</a>, <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>, <a class="el" href="QuEST__cpu_8c_source.html#l02739">statevec_pauliYDistributed()</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l02682">statevec_pauliYLocal()</a>.</p>

</div>
</div>
<a id="ab7478fcaf6357ab202d72853b672e375"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab7478fcaf6357ab202d72853b672e375">&#9670;&nbsp;</a></span>statevec_swapQubitAmps()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_swapQubitAmps </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>qb1</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>qb2</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01354">1354</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l01354"></a><span class="lineno"> 1354</span>&#160;                                                           {</div>
<div class="line"><a name="l01355"></a><span class="lineno"> 1355</span>&#160;    </div>
<div class="line"><a name="l01356"></a><span class="lineno"> 1356</span>&#160;    <span class="comment">// perform locally if possible </span></div>
<div class="line"><a name="l01357"></a><span class="lineno"> 1357</span>&#160;    <span class="keywordtype">int</span> qbBig = (qb1 &gt; qb2)? qb1 : qb2;</div>
<div class="line"><a name="l01358"></a><span class="lineno"> 1358</span>&#160;    <span class="keywordflow">if</span> (<a class="code" href="QuEST__cpu__distributed_8c.html#a4d043bb0cee54a5f94faf3ffc34a6790">halfMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, qbBig))</div>
<div class="line"><a name="l01359"></a><span class="lineno"> 1359</span>&#160;        <span class="keywordflow">return</span> <a class="code" href="QuEST__cpu_8c.html#ab5b51a28caa8792a3f0c637409a694b0">statevec_swapQubitAmpsLocal</a>(qureg, qb1, qb2);</div>
<div class="line"><a name="l01360"></a><span class="lineno"> 1360</span>&#160;        </div>
<div class="line"><a name="l01361"></a><span class="lineno"> 1361</span>&#160;    <span class="comment">// do nothing if this node contains no amplitudes to swap</span></div>
<div class="line"><a name="l01362"></a><span class="lineno"> 1362</span>&#160;    <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> oddParityGlobalInd = <a class="code" href="QuEST__cpu__distributed_8c.html#a4f243eb101c8e63f16cfd50300364cb7">getGlobalIndOfOddParityInChunk</a>(qureg, qb1, qb2);</div>
<div class="line"><a name="l01363"></a><span class="lineno"> 1363</span>&#160;    <span class="keywordflow">if</span> (oddParityGlobalInd == -1)</div>
<div class="line"><a name="l01364"></a><span class="lineno"> 1364</span>&#160;        <span class="keywordflow">return</span>;</div>
<div class="line"><a name="l01365"></a><span class="lineno"> 1365</span>&#160; </div>
<div class="line"><a name="l01366"></a><span class="lineno"> 1366</span>&#160;    <span class="comment">// determine and swap amps with pair node</span></div>
<div class="line"><a name="l01367"></a><span class="lineno"> 1367</span>&#160;    <span class="keywordtype">int</span> pairRank = <a class="code" href="QuEST__gpu_8cu.html#ae1b7788cf504ec3d79de3855f97929c7">flipBit</a>(<a class="code" href="QuEST__gpu_8cu.html#ae1b7788cf504ec3d79de3855f97929c7">flipBit</a>(oddParityGlobalInd, qb1), qb2) / qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>;</div>
<div class="line"><a name="l01368"></a><span class="lineno"> 1368</span>&#160;    <a class="code" href="QuEST__cpu__distributed_8c.html#ae01c3eb75fd32de1a7e1dbc7a33a21e3">exchangeStateVectors</a>(qureg, pairRank);</div>
<div class="line"><a name="l01369"></a><span class="lineno"> 1369</span>&#160;    <a class="code" href="QuEST__cpu_8c.html#abe74a5a9db8340e37b80fbc77338894d">statevec_swapQubitAmpsDistributed</a>(qureg, pairRank, qb1, qb2);</div>
<div class="line"><a name="l01370"></a><span class="lineno"> 1370</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00479">exchangeStateVectors()</a>, <a class="el" href="QuEST__gpu_8cu_source.html#l00095">flipBit()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01335">getGlobalIndOfOddParityInChunk()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00356">halfMatrixBlockFitsInChunk()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST__cpu_8c_source.html#l03579">statevec_swapQubitAmpsDistributed()</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l03536">statevec_swapQubitAmpsLocal()</a>.</p>

<p class="reference">Referenced by <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01437">statevec_multiControlledMultiQubitUnitary()</a>, and <a class="el" href="QuEST__cpu__distributed_8c_source.html#l01381">statevec_multiControlledTwoQubitUnitary()</a>.</p>

</div>
</div>
<a id="ac3735bd959600e57b2ee3a105666cddf"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac3735bd959600e57b2ee3a105666cddf">&#9670;&nbsp;</a></span>statevec_unitary()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void statevec_unitary </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structQureg.html">Qureg</a>&#160;</td>
          <td class="paramname"><em>qureg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>targetQubit</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structComplexMatrix2.html">ComplexMatrix2</a>&#160;</td>
          <td class="paramname"><em>u</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00881">881</a> of file <a class="el" href="QuEST__cpu__distributed_8c_source.html">QuEST_cpu_distributed.c</a>.</p>
<div class="fragment"><div class="line"><a name="l00882"></a><span class="lineno">  882</span>&#160;{</div>
<div class="line"><a name="l00883"></a><span class="lineno">  883</span>&#160;    <span class="comment">// flag to require memory exchange. 1: an entire block fits on one rank, 0: at most half a block fits on one rank</span></div>
<div class="line"><a name="l00884"></a><span class="lineno">  884</span>&#160;    <span class="keywordtype">int</span> useLocalDataOnly = <a class="code" href="QuEST__cpu__distributed_8c.html#a4d043bb0cee54a5f94faf3ffc34a6790">halfMatrixBlockFitsInChunk</a>(qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l00885"></a><span class="lineno">  885</span>&#160;    <a class="code" href="structComplex.html">Complex</a> rot1, rot2;</div>
<div class="line"><a name="l00886"></a><span class="lineno">  886</span>&#160; </div>
<div class="line"><a name="l00887"></a><span class="lineno">  887</span>&#160;    <span class="comment">// rank&#39;s chunk is in upper half of block </span></div>
<div class="line"><a name="l00888"></a><span class="lineno">  888</span>&#160;    <span class="keywordtype">int</span> rankIsUpper;</div>
<div class="line"><a name="l00889"></a><span class="lineno">  889</span>&#160;    <span class="keywordtype">int</span> pairRank; <span class="comment">// rank of corresponding chunk</span></div>
<div class="line"><a name="l00890"></a><span class="lineno">  890</span>&#160; </div>
<div class="line"><a name="l00891"></a><span class="lineno">  891</span>&#160;    <span class="keywordflow">if</span> (useLocalDataOnly){</div>
<div class="line"><a name="l00892"></a><span class="lineno">  892</span>&#160;        <span class="comment">// all values required to update state vector lie in this rank</span></div>
<div class="line"><a name="l00893"></a><span class="lineno">  893</span>&#160;        <a class="code" href="QuEST__cpu_8c.html#aafc398f8f479fcc066a2dea700235635">statevec_unitaryLocal</a>(qureg, targetQubit, u);</div>
<div class="line"><a name="l00894"></a><span class="lineno">  894</span>&#160;    } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00895"></a><span class="lineno">  895</span>&#160;        <span class="comment">// need to get corresponding chunk of state vector from other rank</span></div>
<div class="line"><a name="l00896"></a><span class="lineno">  896</span>&#160;        rankIsUpper = <a class="code" href="QuEST__cpu__distributed_8c.html#a0552889d6f57d9e0ed8b209bf426482d">chunkIsUpper</a>(qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l00897"></a><span class="lineno">  897</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#a5c9b2f129bdffaaba9857f6eddecbb17">getRotAngleFromUnitaryMatrix</a>(rankIsUpper, &amp;rot1, &amp;rot2, u);</div>
<div class="line"><a name="l00898"></a><span class="lineno">  898</span>&#160;        pairRank = <a class="code" href="QuEST__cpu__distributed_8c.html#a7dba097f23f5d48dfdc9f3250444e2e4">getChunkPairId</a>(rankIsUpper, qureg.<a class="code" href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">chunkId</a>, qureg.<a class="code" href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">numAmpsPerChunk</a>, targetQubit);</div>
<div class="line"><a name="l00899"></a><span class="lineno">  899</span>&#160;        <span class="comment">// get corresponding values from my pair</span></div>
<div class="line"><a name="l00900"></a><span class="lineno">  900</span>&#160;        <a class="code" href="QuEST__cpu__distributed_8c.html#ae01c3eb75fd32de1a7e1dbc7a33a21e3">exchangeStateVectors</a>(qureg, pairRank);</div>
<div class="line"><a name="l00901"></a><span class="lineno">  901</span>&#160; </div>
<div class="line"><a name="l00902"></a><span class="lineno">  902</span>&#160;        <span class="comment">// this rank&#39;s values are either in the upper of lower half of the block. </span></div>
<div class="line"><a name="l00903"></a><span class="lineno">  903</span>&#160;        <span class="comment">// send values to compactUnitaryDistributed in the correct order</span></div>
<div class="line"><a name="l00904"></a><span class="lineno">  904</span>&#160;        <span class="keywordflow">if</span> (rankIsUpper){</div>
<div class="line"><a name="l00905"></a><span class="lineno">  905</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#a0ce2c2fd54df25495e99dc5b95bed4b2">statevec_unitaryDistributed</a>(qureg,rot1,rot2,</div>
<div class="line"><a name="l00906"></a><span class="lineno">  906</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>, <span class="comment">//upper</span></div>
<div class="line"><a name="l00907"></a><span class="lineno">  907</span>&#160;                    qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">//lower</span></div>
<div class="line"><a name="l00908"></a><span class="lineno">  908</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>); <span class="comment">//output</span></div>
<div class="line"><a name="l00909"></a><span class="lineno">  909</span>&#160;        } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00910"></a><span class="lineno">  910</span>&#160;            <a class="code" href="QuEST__cpu_8c.html#a0ce2c2fd54df25495e99dc5b95bed4b2">statevec_unitaryDistributed</a>(qureg,rot1,rot2,</div>
<div class="line"><a name="l00911"></a><span class="lineno">  911</span>&#160;                    qureg.<a class="code" href="structQureg.html#aba97773694870ef35e378c036f486bb7">pairStateVec</a>, <span class="comment">//upper</span></div>
<div class="line"><a name="l00912"></a><span class="lineno">  912</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>, <span class="comment">//lower</span></div>
<div class="line"><a name="l00913"></a><span class="lineno">  913</span>&#160;                    qureg.<a class="code" href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">stateVec</a>); <span class="comment">//output</span></div>
<div class="line"><a name="l00914"></a><span class="lineno">  914</span>&#160;        }</div>
<div class="line"><a name="l00915"></a><span class="lineno">  915</span>&#160;    }</div>
<div class="line"><a name="l00916"></a><span class="lineno">  916</span>&#160; </div>
<div class="line"><a name="l00917"></a><span class="lineno">  917</span>&#160; </div>
<div class="line"><a name="l00918"></a><span class="lineno">  918</span>&#160;}</div>
</div><!-- fragment -->
<p class="reference">References <a class="el" href="QuEST_8h_source.html#l00217">Qureg::chunkId</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00227">chunkIsUpper()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00479">exchangeStateVectors()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00303">getChunkPairId()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00283">getRotAngleFromUnitaryMatrix()</a>, <a class="el" href="QuEST__cpu__distributed_8c_source.html#l00356">halfMatrixBlockFitsInChunk()</a>, <a class="el" href="QuEST_8h_source.html#l00213">Qureg::numAmpsPerChunk</a>, <a class="el" href="QuEST_8h_source.html#l00224">Qureg::pairStateVec</a>, <a class="el" href="QuEST_8h_source.html#l00222">Qureg::stateVec</a>, <a class="el" href="QuEST__cpu_8c_source.html#l02056">statevec_unitaryDistributed()</a>, and <a class="el" href="QuEST__cpu_8c_source.html#l01932">statevec_unitaryLocal()</a>.</p>

</div>
</div>
</div><!-- contents -->
<div class="ttc" id="aQuEST__cpu_8c_html_ace1482ef82b83e7f926634a67b322fc4"><div class="ttname"><a href="QuEST__cpu_8c.html#ace1482ef82b83e7f926634a67b322fc4">statevec_controlledNotLocal</a></div><div class="ttdeci">void statevec_controlledNotLocal(Qureg qureg, int controlQubit, int targetQubit)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l02584">QuEST_cpu.c:2584</a></div></div>
<div class="ttc" id="aQuEST__cpu__distributed_8c_html_adb4b0373425b282abed27742d0ce0872"><div class="ttname"><a href="QuEST__cpu__distributed_8c.html#adb4b0373425b282abed27742d0ce0872">getRotAngle</a></div><div class="ttdeci">static void getRotAngle(int chunkIsUpper, Complex *rot1, Complex *rot2, Complex alpha, Complex beta)</div><div class="ttdoc">Get rotation values for a given chunk.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00258">QuEST_cpu_distributed.c:258</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a45b0916c3e121837f214b64f7424e479"><div class="ttname"><a href="QuEST__cpu_8c.html#a45b0916c3e121837f214b64f7424e479">statevec_pauliYLocal</a></div><div class="ttdeci">void statevec_pauliYLocal(Qureg qureg, int targetQubit, int conjFac)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l02682">QuEST_cpu.c:2682</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a939897137596bb73ad7a028d0beaaa10"><div class="ttname"><a href="QuEST__cpu_8c.html#a939897137596bb73ad7a028d0beaaa10">densmatr_calcHilbertSchmidtDistanceSquaredLocal</a></div><div class="ttdeci">qreal densmatr_calcHilbertSchmidtDistanceSquaredLocal(Qureg a, Qureg b)</div><div class="ttdoc">computes Tr((a-b) conjTrans(a-b)) = sum of abs values of (a-b)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l00923">QuEST_cpu.c:923</a></div></div>
<div class="ttc" id="aQuEST__cpu__distributed_8c_html_af0ea25f00987af4c53f17c9cca62ab41"><div class="ttname"><a href="QuEST__cpu__distributed_8c.html#af0ea25f00987af4c53f17c9cca62ab41">isChunkToSkipInFindPZero</a></div><div class="ttdeci">static int isChunkToSkipInFindPZero(int chunkId, long long int chunkSize, int measureQubit)</div><div class="ttdoc">Find chunks to skip when calculating probability of qubit being zero.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l01251">QuEST_cpu_distributed.c:1251</a></div></div>
<div class="ttc" id="astructQureg_html_aba97773694870ef35e378c036f486bb7"><div class="ttname"><a href="structQureg.html#aba97773694870ef35e378c036f486bb7">Qureg::pairStateVec</a></div><div class="ttdeci">ComplexArray pairStateVec</div><div class="ttdoc">Temporary storage for a chunk of the state vector received from another process in the MPI version.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00224">QuEST.h:224</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a430d98e35f1eae7f0815ac539057cf67"><div class="ttname"><a href="QuEST__cpu_8c.html#a430d98e35f1eae7f0815ac539057cf67">statevec_findProbabilityOfZeroDistributed</a></div><div class="ttdeci">qreal statevec_findProbabilityOfZeroDistributed(Qureg qureg)</div><div class="ttdoc">Measure the probability of a specified qubit being in the zero state across all amplitudes held in th...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l03262">QuEST_cpu.c:3262</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a88670d0e7cebe33f61c1dd98daa338b3"><div class="ttname"><a href="QuEST__cpu_8c.html#a88670d0e7cebe33f61c1dd98daa338b3">densmatr_mixDepolarisingDistributed</a></div><div class="ttdeci">void densmatr_mixDepolarisingDistributed(Qureg qureg, int targetQubit, qreal depolLevel)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l00224">QuEST_cpu.c:224</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_acabdfbd3184d3ab3bded61e24142b800"><div class="ttname"><a href="QuEST__cpu_8c.html#acabdfbd3184d3ab3bded61e24142b800">densmatr_mixTwoQubitDepolarisingQ1LocalQ2DistributedPart3</a></div><div class="ttdeci">void densmatr_mixTwoQubitDepolarisingQ1LocalQ2DistributedPart3(Qureg qureg, int targetQubit, int qubit2, qreal delta, qreal gamma)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l00632">QuEST_cpu.c:632</a></div></div>
<div class="ttc" id="astructQureg_html_aa3deb7163aab90a61e755a1f200f5413"><div class="ttname"><a href="structQureg.html#aa3deb7163aab90a61e755a1f200f5413">Qureg::numChunks</a></div><div class="ttdeci">int numChunks</div><div class="ttdoc">Number of chunks the state vector is broken up into – the number of MPI processes used.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00219">QuEST.h:219</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_ab5b51a28caa8792a3f0c637409a694b0"><div class="ttname"><a href="QuEST__cpu_8c.html#ab5b51a28caa8792a3f0c637409a694b0">statevec_swapQubitAmpsLocal</a></div><div class="ttdeci">void statevec_swapQubitAmpsLocal(Qureg qureg, int qb1, int qb2)</div><div class="ttdoc">It is ensured that all amplitudes needing to be swapped are on this node.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l03536">QuEST_cpu.c:3536</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_ab58fe4be895283c2c4eb86ec9af5682e"><div class="ttname"><a href="QuEST__cpu_8c.html#ab58fe4be895283c2c4eb86ec9af5682e">statevec_multiControlledUnitaryDistributed</a></div><div class="ttdeci">void statevec_multiControlledUnitaryDistributed(Qureg qureg, int targetQubit, long long int ctrlQubitsMask, long long int ctrlFlipMask, Complex rot1, Complex rot2, ComplexArray stateVecUp, ComplexArray stateVecLo, ComplexArray stateVecOut)</div><div class="ttdoc">Apply a unitary operation to a single qubit in the state vector of probability amplitudes,...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l02447">QuEST_cpu.c:2447</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a57368529b2a7e76fec423cbfe9980b22"><div class="ttname"><a href="QuEST__cpu_8c.html#a57368529b2a7e76fec423cbfe9980b22">statevec_controlledUnitaryDistributed</a></div><div class="ttdeci">void statevec_controlledUnitaryDistributed(Qureg qureg, int controlQubit, Complex rot1, Complex rot2, ComplexArray stateVecUp, ComplexArray stateVecLo, ComplexArray stateVecOut)</div><div class="ttdoc">Rotate a single qubit in the state vector of probability amplitudes, given two complex numbers alpha ...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l02381">QuEST_cpu.c:2381</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_ab02bce0ebbb8f624e8ced8b09b99cdef"><div class="ttname"><a href="QuEST__cpu_8c.html#ab02bce0ebbb8f624e8ced8b09b99cdef">statevec_collapseToKnownProbOutcomeLocal</a></div><div class="ttdeci">void statevec_collapseToKnownProbOutcomeLocal(Qureg qureg, int measureQubit, int outcome, qreal totalProbability)</div><div class="ttdoc">Update the state vector to be consistent with measuring measureQubit=0 if outcome=0 and measureQubit=...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l03380">QuEST_cpu.c:3380</a></div></div>
<div class="ttc" id="aQuEST__cpu__distributed_8c_html_a373394db1bf71b0be63585c0e9a52abb"><div class="ttname"><a href="QuEST__cpu__distributed_8c.html#a373394db1bf71b0be63585c0e9a52abb">compressPairVectorForTwoQubitDepolarise</a></div><div class="ttdeci">void compressPairVectorForTwoQubitDepolarise(Qureg qureg, int targetQubit, int qubit2)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00610">QuEST_cpu_distributed.c:610</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a5ddfdb22e4704b680d67d08d9e80835b"><div class="ttname"><a href="QuEST__cpu_8c.html#a5ddfdb22e4704b680d67d08d9e80835b">statevec_compactUnitaryLocal</a></div><div class="ttdeci">void statevec_compactUnitaryLocal(Qureg qureg, int targetQubit, Complex alpha, Complex beta)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l01688">QuEST_cpu.c:1688</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_af910c7cf2b85bdc2c399cfe8dbfb8b9c"><div class="ttname"><a href="QuEST__cpu_8c.html#af910c7cf2b85bdc2c399cfe8dbfb8b9c">densmatr_calcPurityLocal</a></div><div class="ttdeci">qreal densmatr_calcPurityLocal(Qureg qureg)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l00861">QuEST_cpu.c:861</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a16ccb485bcffb328bbd5b2af6977cead"><div class="ttname"><a href="QuEST__cpu_8c.html#a16ccb485bcffb328bbd5b2af6977cead">statevec_calcExpecDiagonalOpLocal</a></div><div class="ttdeci">Complex statevec_calcExpecDiagonalOpLocal(Qureg qureg, DiagonalOp op)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l03738">QuEST_cpu.c:3738</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a0aedcccfa50c7aaa8b7fc4c14d7cdfb8"><div class="ttname"><a href="QuEST__cpu_8c.html#a0aedcccfa50c7aaa8b7fc4c14d7cdfb8">statevec_multiControlledMultiQubitUnitaryLocal</a></div><div class="ttdeci">void statevec_multiControlledMultiQubitUnitaryLocal(Qureg qureg, long long int ctrlMask, int *targs, int numTargs, ComplexMatrixN u)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l01846">QuEST_cpu.c:1846</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_af8236a00389137b5eff986a40577eaf3"><div class="ttname"><a href="QuEST__cpu_8c.html#af8236a00389137b5eff986a40577eaf3">statevec_multiControlledTwoQubitUnitaryLocal</a></div><div class="ttdeci">void statevec_multiControlledTwoQubitUnitaryLocal(Qureg qureg, long long int ctrlMask, int q1, int q2, ComplexMatrix4 u)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l01747">QuEST_cpu.c:1747</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a464efbd1d7ca5a7b25c83ada001955c2"><div class="ttname"><a href="QuEST__cpu_8c.html#a464efbd1d7ca5a7b25c83ada001955c2">statevec_pauliXDistributed</a></div><div class="ttdeci">void statevec_pauliXDistributed(Qureg qureg, ComplexArray stateVecIn, ComplexArray stateVecOut)</div><div class="ttdoc">Rotate a single qubit by {{0,1},{1,0}.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l02556">QuEST_cpu.c:2556</a></div></div>
<div class="ttc" id="aQuEST__cpu__distributed_8c_html_ae66dc6569c6e4008c33d6739db422c08"><div class="ttname"><a href="QuEST__cpu__distributed_8c.html#ae66dc6569c6e4008c33d6739db422c08">getChunkOuterBlockPairId</a></div><div class="ttdeci">static int getChunkOuterBlockPairId(int chunkIsUpper, int chunkId, long long int chunkSize, int targetQubit, int numQubits)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00314">QuEST_cpu_distributed.c:314</a></div></div>
<div class="ttc" id="aQuEST__cpu__distributed_8c_html_a95af772d87c461fc8abfd6d47b752ac2"><div class="ttname"><a href="QuEST__cpu__distributed_8c.html#a95af772d87c461fc8abfd6d47b752ac2">copyVecIntoMatrixPairState</a></div><div class="ttdeci">void copyVecIntoMatrixPairState(Qureg matr, Qureg vec)</div><div class="ttdoc">This copies/clones vec (a statevector) into every node's matr pairState.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00371">QuEST_cpu_distributed.c:371</a></div></div>
<div class="ttc" id="agroup__type_html_ga7740e349b4f8bae6451547680f0ce2d6"><div class="ttname"><a href="group__type.html#ga7740e349b4f8bae6451547680f0ce2d6">qreal</a></div><div class="ttdeci">#define qreal</div></div>
<div class="ttc" id="aQuEST__cpu__distributed_8c_html_a37dae401754961c9100b3c0907913c3e"><div class="ttname"><a href="QuEST__cpu__distributed_8c.html#a37dae401754961c9100b3c0907913c3e">exchangePairStateVectorHalves</a></div><div class="ttdeci">void exchangePairStateVectorHalves(Qureg qureg, int pairRank)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00509">QuEST_cpu_distributed.c:509</a></div></div>
<div class="ttc" id="aQuEST__gpu_8cu_html_ae1b7788cf504ec3d79de3855f97929c7"><div class="ttname"><a href="QuEST__gpu_8cu.html#ae1b7788cf504ec3d79de3855f97929c7">flipBit</a></div><div class="ttdeci">__forceinline__ __device__ long long int flipBit(const long long int number, const int bitInd)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__gpu_8cu_source.html#l00095">QuEST_gpu.cu:95</a></div></div>
<div class="ttc" id="aQuEST__cpu__distributed_8c_html_ab7478fcaf6357ab202d72853b672e375"><div class="ttname"><a href="QuEST__cpu__distributed_8c.html#ab7478fcaf6357ab202d72853b672e375">statevec_swapQubitAmps</a></div><div class="ttdeci">void statevec_swapQubitAmps(Qureg qureg, int qb1, int qb2)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l01354">QuEST_cpu_distributed.c:1354</a></div></div>
<div class="ttc" id="aQuEST__cpu__distributed_8c_html_a7dba097f23f5d48dfdc9f3250444e2e4"><div class="ttname"><a href="QuEST__cpu__distributed_8c.html#a7dba097f23f5d48dfdc9f3250444e2e4">getChunkPairId</a></div><div class="ttdeci">static int getChunkPairId(int chunkIsUpper, int chunkId, long long int chunkSize, int targetQubit)</div><div class="ttdoc">get position of corresponding chunk, holding values required to update values in my chunk (with chunk...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00303">QuEST_cpu_distributed.c:303</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a7ea68e9132ed9db9c242353a33dba2f0"><div class="ttname"><a href="QuEST__cpu_8c.html#a7ea68e9132ed9db9c242353a33dba2f0">statevec_collapseToOutcomeDistributedSetZero</a></div><div class="ttdeci">void statevec_collapseToOutcomeDistributedSetZero(Qureg qureg)</div><div class="ttdoc">Set all amplitudes in one chunk to 0.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l03501">QuEST_cpu.c:3501</a></div></div>
<div class="ttc" id="astructQureg_html_ac2929e681d3d95591c18cf168dbbe4f0"><div class="ttname"><a href="structQureg.html#ac2929e681d3d95591c18cf168dbbe4f0">Qureg::chunkId</a></div><div class="ttdeci">int chunkId</div><div class="ttdoc">The position of the chunk of the state vector held by this process in the full state vector.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00217">QuEST.h:217</a></div></div>
<div class="ttc" id="astructComplexMatrix2_html_a3a2b60a9e00ccef054a6de3b9307c1be"><div class="ttname"><a href="structComplexMatrix2.html#a3a2b60a9e00ccef054a6de3b9307c1be">ComplexMatrix2::imag</a></div><div class="ttdeci">qreal imag[2][2]</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00117">QuEST.h:117</a></div></div>
<div class="ttc" id="astructDiagonalOp_html_a85c3f52533efe831bbe40b9a48602388"><div class="ttname"><a href="structDiagonalOp.html#a85c3f52533efe831bbe40b9a48602388">DiagonalOp::imag</a></div><div class="ttdeci">qreal * imag</div><div class="ttdoc">The imaginary values of the 2^numQubits complex elements.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00191">QuEST.h:191</a></div></div>
<div class="ttc" id="aQuEST__cpu__distributed_8c_html_a0eb14d48920ea469b0904ae63b47b589"><div class="ttname"><a href="QuEST__cpu__distributed_8c.html#a0eb14d48920ea469b0904ae63b47b589">compressPairVectorForSingleQubitDepolarise</a></div><div class="ttdeci">void compressPairVectorForSingleQubitDepolarise(Qureg qureg, int targetQubit)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00543">QuEST_cpu_distributed.c:543</a></div></div>
<div class="ttc" id="astructQureg_html_ab0ea0358482b62f43fdd781469607d97"><div class="ttname"><a href="structQureg.html#ab0ea0358482b62f43fdd781469607d97">Qureg::numAmpsPerChunk</a></div><div class="ttdeci">long long int numAmpsPerChunk</div><div class="ttdoc">Number of probability amplitudes held in stateVec by this process In the non-MPI version,...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00213">QuEST.h:213</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a3510f01d4d15dcc545564eb84c668cad"><div class="ttname"><a href="QuEST__cpu_8c.html#a3510f01d4d15dcc545564eb84c668cad">densmatr_mixTwoQubitDepolarisingLocal</a></div><div class="ttdeci">void densmatr_mixTwoQubitDepolarisingLocal(Qureg qureg, int qubit1, int qubit2, qreal delta, qreal gamma)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l00387">QuEST_cpu.c:387</a></div></div>
<div class="ttc" id="aQuEST__cpu__distributed_8c_html_a5c9b2f129bdffaaba9857f6eddecbb17"><div class="ttname"><a href="QuEST__cpu__distributed_8c.html#a5c9b2f129bdffaaba9857f6eddecbb17">getRotAngleFromUnitaryMatrix</a></div><div class="ttdeci">static void getRotAngleFromUnitaryMatrix(int chunkIsUpper, Complex *rot1, Complex *rot2, ComplexMatrix2 u)</div><div class="ttdoc">Get rotation values for a given chunk given a unitary matrix.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00283">QuEST_cpu_distributed.c:283</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a06fb16aa4af7c54d36052a14d3ad58a7"><div class="ttname"><a href="QuEST__cpu_8c.html#a06fb16aa4af7c54d36052a14d3ad58a7">statevec_controlledPauliYLocal</a></div><div class="ttdeci">void statevec_controlledPauliYLocal(Qureg qureg, int controlQubit, int targetQubit, int conjFac)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l02776">QuEST_cpu.c:2776</a></div></div>
<div class="ttc" id="aQuEST__internal_8h_html_a623e577b7230f3c8dc202be6185b4289"><div class="ttname"><a href="QuEST__internal_8h.html#a623e577b7230f3c8dc202be6185b4289">densmatr_mixTwoQubitDephasing</a></div><div class="ttdeci">void densmatr_mixTwoQubitDephasing(Qureg qureg, int qubit1, int qubit2, qreal dephase)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l00084">QuEST_cpu.c:84</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a0a7a35628b1c1eb47336deb9afda5b68"><div class="ttname"><a href="QuEST__cpu_8c.html#a0a7a35628b1c1eb47336deb9afda5b68">statevec_compactUnitaryDistributed</a></div><div class="ttdeci">void statevec_compactUnitaryDistributed(Qureg qureg, Complex rot1, Complex rot2, ComplexArray stateVecUp, ComplexArray stateVecLo, ComplexArray stateVecOut)</div><div class="ttdoc">Rotate a single qubit in the state vector of probability amplitudes, given two complex numbers alpha ...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l02001">QuEST_cpu.c:2001</a></div></div>
<div class="ttc" id="aQuEST__cpu__distributed_8c_html_ae01c3eb75fd32de1a7e1dbc7a33a21e3"><div class="ttname"><a href="QuEST__cpu__distributed_8c.html#ae01c3eb75fd32de1a7e1dbc7a33a21e3">exchangeStateVectors</a></div><div class="ttdeci">void exchangeStateVectors(Qureg qureg, int pairRank)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00479">QuEST_cpu_distributed.c:479</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_ab19f28e68330da68ea3caa2bdef32da9"><div class="ttname"><a href="QuEST__cpu_8c.html#ab19f28e68330da68ea3caa2bdef32da9">statevec_multiControlledUnitaryLocal</a></div><div class="ttdeci">void statevec_multiControlledUnitaryLocal(Qureg qureg, int targetQubit, long long int ctrlQubitsMask, long long int ctrlFlipMask, ComplexMatrix2 u)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l02173">QuEST_cpu.c:2173</a></div></div>
<div class="ttc" id="aQuEST__common_8c_html_acc45bb8300922ea5933e294921e25ea2"><div class="ttname"><a href="QuEST__common_8c.html#acc45bb8300922ea5933e294921e25ea2">getQubitBitMask</a></div><div class="ttdeci">long long int getQubitBitMask(int *qubits, int numQubits)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__common_8c_source.html#l00044">QuEST_common.c:44</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a0f562af6cb665a8a7a3f80e9449734d5"><div class="ttname"><a href="QuEST__cpu_8c.html#a0f562af6cb665a8a7a3f80e9449734d5">statevec_pauliYDistributed</a></div><div class="ttdeci">void statevec_pauliYDistributed(Qureg qureg, ComplexArray stateVecIn, ComplexArray stateVecOut, int updateUpper, int conjFac)</div><div class="ttdoc">Rotate a single qubit by +-{{0,-i},{i,0}.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l02739">QuEST_cpu.c:2739</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a8d9c19a3424f0ad89bfbfd920d65301d"><div class="ttname"><a href="QuEST__cpu_8c.html#a8d9c19a3424f0ad89bfbfd920d65301d">densmatr_mixDampingDistributed</a></div><div class="ttdeci">void densmatr_mixDampingDistributed(Qureg qureg, int targetQubit, qreal damping)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l00300">QuEST_cpu.c:300</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_aeb4453a2e609e5359d2995bccf6663ca"><div class="ttname"><a href="QuEST__cpu_8c.html#aeb4453a2e609e5359d2995bccf6663ca">densmatr_calcExpecDiagonalOpLocal</a></div><div class="ttdeci">Complex densmatr_calcExpecDiagonalOpLocal(Qureg qureg, DiagonalOp op)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l03781">QuEST_cpu.c:3781</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_aa987d1e0ba97da2ca540194356dd62de"><div class="ttname"><a href="QuEST__cpu_8c.html#aa987d1e0ba97da2ca540194356dd62de">statevec_pauliXLocal</a></div><div class="ttdeci">void statevec_pauliXLocal(Qureg qureg, int targetQubit)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l02498">QuEST_cpu.c:2498</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a1b36518c8fbbc3a5084bb4ad1fb05ea5"><div class="ttname"><a href="QuEST__cpu_8c.html#a1b36518c8fbbc3a5084bb4ad1fb05ea5">densmatr_initPureStateLocal</a></div><div class="ttdeci">void densmatr_initPureStateLocal(Qureg targetQureg, Qureg copyQureg)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l01184">QuEST_cpu.c:1184</a></div></div>
<div class="ttc" id="aQuEST__gpu_8cu_html_aec1852e1a8e70d3690919ce8ab551ba0"><div class="ttname"><a href="QuEST__gpu_8cu.html#aec1852e1a8e70d3690919ce8ab551ba0">extractBit</a></div><div class="ttdeci">__forceinline__ __device__ int extractBit(const int locationOfBitFromRight, const long long int theEncodedNumber)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__gpu_8cu_source.html#l00082">QuEST_gpu.cu:82</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_ab124a3a9956046bf9c0e1e3ae9171f42"><div class="ttname"><a href="QuEST__cpu_8c.html#ab124a3a9956046bf9c0e1e3ae9171f42">densmatr_mixDampingLocal</a></div><div class="ttdeci">void densmatr_mixDampingLocal(Qureg qureg, int targetQubit, qreal damping)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l00174">QuEST_cpu.c:174</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a08392b1b27d10e3b8a8648a5afeaa629"><div class="ttname"><a href="QuEST__cpu_8c.html#a08392b1b27d10e3b8a8648a5afeaa629">densmatr_calcInnerProductLocal</a></div><div class="ttdeci">qreal densmatr_calcInnerProductLocal(Qureg a, Qureg b)</div><div class="ttdoc">computes Tr(conjTrans(a) b) = sum of (a_ij^* b_ij)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l00958">QuEST_cpu.c:958</a></div></div>
<div class="ttc" id="aQuEST__cpu__distributed_8c_html_a28be36627b2dd9a0da63dd6f60121b06"><div class="ttname"><a href="QuEST__cpu__distributed_8c.html#a28be36627b2dd9a0da63dd6f60121b06">getChunkIdFromIndex</a></div><div class="ttdeci">static int getChunkIdFromIndex(Qureg qureg, long long int index)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00194">QuEST_cpu_distributed.c:194</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a0ce2c2fd54df25495e99dc5b95bed4b2"><div class="ttname"><a href="QuEST__cpu_8c.html#a0ce2c2fd54df25495e99dc5b95bed4b2">statevec_unitaryDistributed</a></div><div class="ttdeci">void statevec_unitaryDistributed(Qureg qureg, Complex rot1, Complex rot2, ComplexArray stateVecUp, ComplexArray stateVecLo, ComplexArray stateVecOut)</div><div class="ttdoc">Apply a unitary operation to a single qubit given a subset of the state vector with upper and lower b...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l02056">QuEST_cpu.c:2056</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a071baf8b6951d2a7d6529394b6f39364"><div class="ttname"><a href="QuEST__cpu_8c.html#a071baf8b6951d2a7d6529394b6f39364">statevec_controlledCompactUnitaryDistributed</a></div><div class="ttdeci">void statevec_controlledCompactUnitaryDistributed(Qureg qureg, int controlQubit, Complex rot1, Complex rot2, ComplexArray stateVecUp, ComplexArray stateVecLo, ComplexArray stateVecOut)</div><div class="ttdoc">Rotate a single qubit in the state vector of probability amplitudes, given two complex numbers alpha ...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l02319">QuEST_cpu.c:2319</a></div></div>
<div class="ttc" id="aQuEST__cpu__distributed_8c_html_a076fe6125da4d6037b8bc4d912df4015"><div class="ttname"><a href="QuEST__cpu__distributed_8c.html#a076fe6125da4d6037b8bc4d912df4015">densityMatrixBlockFitsInChunk</a></div><div class="ttdeci">static int densityMatrixBlockFitsInChunk(long long int chunkSize, int numQubits, int targetQubit)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00363">QuEST_cpu_distributed.c:363</a></div></div>
<div class="ttc" id="astructQureg_html_a441e4cacef6bd17adb9813c7442d42fe"><div class="ttname"><a href="structQureg.html#a441e4cacef6bd17adb9813c7442d42fe">Qureg::stateVec</a></div><div class="ttdeci">ComplexArray stateVec</div><div class="ttdoc">Computational state amplitudes - a subset thereof in the MPI version.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00222">QuEST.h:222</a></div></div>
<div class="ttc" id="astructComplexMatrix2_html_a3ea98d545b67a190ee6abe936c72076f"><div class="ttname"><a href="structComplexMatrix2.html#a3ea98d545b67a190ee6abe936c72076f">ComplexMatrix2::real</a></div><div class="ttdeci">qreal real[2][2]</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00116">QuEST.h:116</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_ab750fb47da2fca9849c678c869e40e69"><div class="ttname"><a href="QuEST__cpu_8c.html#ab750fb47da2fca9849c678c869e40e69">densmatr_mixDepolarisingLocal</a></div><div class="ttdeci">void densmatr_mixDepolarisingLocal(Qureg qureg, int targetQubit, qreal depolLevel)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l00125">QuEST_cpu.c:125</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_ad09bb76ad67581b03ab176832cca37cf"><div class="ttname"><a href="QuEST__cpu_8c.html#ad09bb76ad67581b03ab176832cca37cf">statevec_collapseToKnownProbOutcomeDistributedRenorm</a></div><div class="ttdeci">void statevec_collapseToKnownProbOutcomeDistributedRenorm(Qureg qureg, int measureQubit, qreal totalProbability)</div><div class="ttdoc">Renormalise parts of the state vector where measureQubit=0 or 1, based on the total probability of th...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l03462">QuEST_cpu.c:3462</a></div></div>
<div class="ttc" id="aQuEST__cpu__distributed_8c_html_a4d043bb0cee54a5f94faf3ffc34a6790"><div class="ttname"><a href="QuEST__cpu__distributed_8c.html#a4d043bb0cee54a5f94faf3ffc34a6790">halfMatrixBlockFitsInChunk</a></div><div class="ttdeci">static int halfMatrixBlockFitsInChunk(long long int chunkSize, int targetQubit)</div><div class="ttdoc">return whether the current qubit rotation will use blocks that fit within a single chunk.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00356">QuEST_cpu_distributed.c:356</a></div></div>
<div class="ttc" id="astructDiagonalOp_html_a2c6eab631ef48b4978db026c98180eee"><div class="ttname"><a href="structDiagonalOp.html#a2c6eab631ef48b4978db026c98180eee">DiagonalOp::numElemsPerChunk</a></div><div class="ttdeci">long long int numElemsPerChunk</div><div class="ttdoc">The number of the 2^numQubits amplitudes stored on each distributed node.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00183">QuEST.h:183</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a86dbcc3db99294add9964741e19fbdab"><div class="ttname"><a href="QuEST__cpu_8c.html#a86dbcc3db99294add9964741e19fbdab">statevec_hadamardLocal</a></div><div class="ttdeci">void statevec_hadamardLocal(Qureg qureg, int targetQubit)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l02872">QuEST_cpu.c:2872</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_afa58cf7cb98a25ab33621120c5c330d0"><div class="ttname"><a href="QuEST__cpu_8c.html#afa58cf7cb98a25ab33621120c5c330d0">densmatr_applyDiagonalOpLocal</a></div><div class="ttdeci">void densmatr_applyDiagonalOpLocal(Qureg qureg, DiagonalOp op)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l03696">QuEST_cpu.c:3696</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a903beb4f5d8753a964ce2dc5f9096a24"><div class="ttname"><a href="QuEST__cpu_8c.html#a903beb4f5d8753a964ce2dc5f9096a24">statevec_controlledUnitaryLocal</a></div><div class="ttdeci">void statevec_controlledUnitaryLocal(Qureg qureg, int controlQubit, int targetQubit, ComplexMatrix2 u)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l02241">QuEST_cpu.c:2241</a></div></div>
<div class="ttc" id="aQuEST__cpu__distributed_8c_html_a4f243eb101c8e63f16cfd50300364cb7"><div class="ttname"><a href="QuEST__cpu__distributed_8c.html#a4f243eb101c8e63f16cfd50300364cb7">getGlobalIndOfOddParityInChunk</a></div><div class="ttdeci">long long int getGlobalIndOfOddParityInChunk(Qureg qureg, int qb1, int qb2)</div><div class="ttdoc">returns -1 if this node contains no amplitudes where qb1 and qb2 have opposite parity,...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l01335">QuEST_cpu_distributed.c:1335</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_ae90f82418e0aa67218d733dbbc681998"><div class="ttname"><a href="QuEST__cpu_8c.html#ae90f82418e0aa67218d733dbbc681998">densmatr_mixTwoQubitDepolarisingLocalPart1</a></div><div class="ttdeci">void densmatr_mixTwoQubitDepolarisingLocalPart1(Qureg qureg, int qubit1, int qubit2, qreal delta)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l00488">QuEST_cpu.c:488</a></div></div>
<div class="ttc" id="aQuEST__cpu__distributed_8c_html_aefba328e047e6ef4fd1ae4b56901aaa7"><div class="ttname"><a href="QuEST__cpu__distributed_8c.html#aefba328e047e6ef4fd1ae4b56901aaa7">copyDiagOpIntoMatrixPairState</a></div><div class="ttdeci">void copyDiagOpIntoMatrixPairState(Qureg qureg, DiagonalOp op)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l01482">QuEST_cpu_distributed.c:1482</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a393da4c4bc582a757ca8406d8501aca0"><div class="ttname"><a href="QuEST__cpu_8c.html#a393da4c4bc582a757ca8406d8501aca0">statevec_controlledNotDistributed</a></div><div class="ttdeci">void statevec_controlledNotDistributed(Qureg qureg, int controlQubit, ComplexArray stateVecIn, ComplexArray stateVecOut)</div><div class="ttdoc">Rotate a single qubit by {{0,1},{1,0}.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l02646">QuEST_cpu.c:2646</a></div></div>
<div class="ttc" id="astructQureg_html_ad08dff5316b8937f4b2a1417591543dc"><div class="ttname"><a href="structQureg.html#ad08dff5316b8937f4b2a1417591543dc">Qureg::numQubitsRepresented</a></div><div class="ttdeci">int numQubitsRepresented</div><div class="ttdoc">The number of qubits represented in either the state-vector or density matrix.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00208">QuEST.h:208</a></div></div>
<div class="ttc" id="astructDiagonalOp_html_a1d66088bed235d524cd452b107694d5c"><div class="ttname"><a href="structDiagonalOp.html#a1d66088bed235d524cd452b107694d5c">DiagonalOp::real</a></div><div class="ttdeci">qreal * real</div><div class="ttdoc">The real values of the 2^numQubits complex elements.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00189">QuEST.h:189</a></div></div>
<div class="ttc" id="astructComplex_html_ab5b2e2eca02131fc74b289a83636cbe3"><div class="ttname"><a href="structComplex.html#ab5b2e2eca02131fc74b289a83636cbe3">Complex::real</a></div><div class="ttdeci">qreal real</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00105">QuEST.h:105</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_abe74a5a9db8340e37b80fbc77338894d"><div class="ttname"><a href="QuEST__cpu_8c.html#abe74a5a9db8340e37b80fbc77338894d">statevec_swapQubitAmpsDistributed</a></div><div class="ttdeci">void statevec_swapQubitAmpsDistributed(Qureg qureg, int pairRank, int qb1, int qb2)</div><div class="ttdoc">qureg.pairStateVec contains the entire set of amplitudes of the paired node which includes the set of...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l03579">QuEST_cpu.c:3579</a></div></div>
<div class="ttc" id="astructComplex_html_a84f5439aad0ef495efdd3b4c1c02d27e"><div class="ttname"><a href="structComplex.html#a84f5439aad0ef495efdd3b4c1c02d27e">Complex::imag</a></div><div class="ttdeci">qreal imag</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00106">QuEST.h:106</a></div></div>
<div class="ttc" id="aQuEST__cpu__distributed_8c_html_ab1ec7f241b68b079c8e316d190af49ce"><div class="ttname"><a href="QuEST__cpu__distributed_8c.html#ab1ec7f241b68b079c8e316d190af49ce">getChunkOuterBlockPairIdForPart3</a></div><div class="ttdeci">static int getChunkOuterBlockPairIdForPart3(int chunkIsUpperSmallerQubit, int chunkIsUpperBiggerQubit, int chunkId, long long int chunkSize, int smallerQubit, int biggerQubit, int numQubits)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00325">QuEST_cpu_distributed.c:325</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a2f76ec8f08e19bb8e1254aafb10e160e"><div class="ttname"><a href="QuEST__cpu_8c.html#a2f76ec8f08e19bb8e1254aafb10e160e">densmatr_mixTwoQubitDepolarisingDistributed</a></div><div class="ttdeci">void densmatr_mixTwoQubitDepolarisingDistributed(Qureg qureg, int targetQubit, int qubit2, qreal delta, qreal gamma)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l00541">QuEST_cpu.c:541</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_aafc398f8f479fcc066a2dea700235635"><div class="ttname"><a href="QuEST__cpu_8c.html#aafc398f8f479fcc066a2dea700235635">statevec_unitaryLocal</a></div><div class="ttdeci">void statevec_unitaryLocal(Qureg qureg, int targetQubit, ComplexMatrix2 u)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l01932">QuEST_cpu.c:1932</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a8bea931504c90d9bd97e74645667804e"><div class="ttname"><a href="QuEST__cpu_8c.html#a8bea931504c90d9bd97e74645667804e">densmatr_findProbabilityOfZeroLocal</a></div><div class="ttdeci">qreal densmatr_findProbabilityOfZeroLocal(Qureg qureg, int measureQubit)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l03151">QuEST_cpu.c:3151</a></div></div>
<div class="ttc" id="aQuEST__cpu__distributed_8c_html_aa3c2d644a2be7f0d3aa9f757527d306f"><div class="ttname"><a href="QuEST__cpu__distributed_8c.html#aa3c2d644a2be7f0d3aa9f757527d306f">chunkIsUpperInOuterBlock</a></div><div class="ttdeci">static int chunkIsUpperInOuterBlock(int chunkId, long long int chunkSize, int targetQubit, int numQubits)</div><div class="ttdoc">fix – do with masking instead</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00236">QuEST_cpu_distributed.c:236</a></div></div>
<div class="ttc" id="astructComplex_html"><div class="ttname"><a href="structComplex.html">Complex</a></div><div class="ttdoc">Represents one complex number.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST_8h_source.html#l00103">QuEST.h:103</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_abea6570b95fdfa102511ccd1fcb30685"><div class="ttname"><a href="QuEST__cpu_8c.html#abea6570b95fdfa102511ccd1fcb30685">statevec_hadamardDistributed</a></div><div class="ttdeci">void statevec_hadamardDistributed(Qureg qureg, ComplexArray stateVecUp, ComplexArray stateVecLo, ComplexArray stateVecOut, int updateUpper)</div><div class="ttdoc">Rotate a single qubit by {{1,1},{1,-1}}/sqrt2.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l02932">QuEST_cpu.c:2932</a></div></div>
<div class="ttc" id="aQuEST__cpu__internal_8h_html_ae94d012c3da6c84599e99f6afea81f5f"><div class="ttname"><a href="QuEST__cpu__internal_8h.html#ae94d012c3da6c84599e99f6afea81f5f">maskContainsBit</a></div><div class="ttdeci">static int maskContainsBit(const long long int mask, const int bitInd)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__internal_8h_source.html#l00034">QuEST_cpu_internal.h:34</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a790add229738945812ae2048c03d58ec"><div class="ttname"><a href="QuEST__cpu_8c.html#a790add229738945812ae2048c03d58ec">statevec_controlledPauliYDistributed</a></div><div class="ttdeci">void statevec_controlledPauliYDistributed(Qureg qureg, int controlQubit, ComplexArray stateVecIn, ComplexArray stateVecOut, int conjFac)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l02830">QuEST_cpu.c:2830</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a215e2d6f88dbecc0b408b3573b5e144f"><div class="ttname"><a href="QuEST__cpu_8c.html#a215e2d6f88dbecc0b408b3573b5e144f">statevec_controlledCompactUnitaryLocal</a></div><div class="ttdeci">void statevec_controlledCompactUnitaryLocal(Qureg qureg, int controlQubit, int targetQubit, Complex alpha, Complex beta)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l02101">QuEST_cpu.c:2101</a></div></div>
<div class="ttc" id="aQuEST__cpu__distributed_8c_html_a0552889d6f57d9e0ed8b209bf426482d"><div class="ttname"><a href="QuEST__cpu__distributed_8c.html#a0552889d6f57d9e0ed8b209bf426482d">chunkIsUpper</a></div><div class="ttdeci">static int chunkIsUpper(int chunkId, long long int chunkSize, int targetQubit)</div><div class="ttdoc">Returns whether a given chunk in position chunkId is in the upper or lower half of a block.</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu__distributed_8c_source.html#l00227">QuEST_cpu_distributed.c:227</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a6fbb3b693f25dde1e9e3dc87dc1984f7"><div class="ttname"><a href="QuEST__cpu_8c.html#a6fbb3b693f25dde1e9e3dc87dc1984f7">statevec_calcInnerProductLocal</a></div><div class="ttdeci">Complex statevec_calcInnerProductLocal(Qureg bra, Qureg ket)</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l01071">QuEST_cpu.c:1071</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a7772f97cb4d92a9825bf3b7c82c3230c"><div class="ttname"><a href="QuEST__cpu_8c.html#a7772f97cb4d92a9825bf3b7c82c3230c">densmatr_calcFidelityLocal</a></div><div class="ttdeci">qreal densmatr_calcFidelityLocal(Qureg qureg, Qureg pureState)</div><div class="ttdoc">computes a few dens-columns-worth of (vec^*T) dens * vec</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l00990">QuEST_cpu.c:990</a></div></div>
<div class="ttc" id="aQuEST__cpu_8c_html_a8535bc15c2ff249ddddb3fde6eff1490"><div class="ttname"><a href="QuEST__cpu_8c.html#a8535bc15c2ff249ddddb3fde6eff1490">statevec_findProbabilityOfZeroLocal</a></div><div class="ttdeci">qreal statevec_findProbabilityOfZeroLocal(Qureg qureg, int measureQubit)</div><div class="ttdoc">Measure the total probability of a specified qubit being in the zero state across all amplitudes in t...</div><div class="ttdef"><b>Definition:</b> <a href="QuEST__cpu_8c_source.html#l03206">QuEST_cpu.c:3206</a></div></div>
<!-- HTML footer for doxygen 1.8.8-->
<!-- start footer part -->
</div>
</div>
</div>
</div>
</div>
</body>
        <script type="text/javascript" src="boot.js"></script>
</html>
